View file tennis/tennis/registration.php

File size: 2.63Kb
<?php
/** Author: ArseN
/*	icq: 799956
/*	email: [email protected]
/*	site: http://softmob.ru
*/
header("Content-type: text/html; charset=UTF-8");
include "config.php";

echo "<html> \n";
echo "<head> \n";
echo "<title>Регистрация</title> \n";

if (!empty($_POST['name']) && !empty($_POST['mail']) && !empty($_POST['pass']))
{
	$name = $_POST['name'];
	$mail = $_POST['mail'];
	$pass = md5($_POST['pass']);
	
	// проверка наличия такого пользователя в базе
	$result_user = mysql_query("SELECT * FROM `users` WHERE `name`='$name';");
	$count_user = mysql_num_rows($result_user);
	if ($count_user > 0)
	{
		echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" />\n";
		echo "</head><body>";
		echo "Пользователь с таким логоном уже зарегистрирован! <br/>\n";
		echo "</body></html>";
		exit;
	}
	// запись пользователя в базу
	$sql="INSERT INTO `users` VALUES ('','$name','$mail',100,'$pass')";
	@mysql_query($sql);
	$uid = mysql_insert_id();
	if ($uid == 0)
	{
		echo "</head><body>";
		echo "Не зарегистрированно! \n";
		echo "</body></html>";
		exit;
	}
	echo "<meta http-equiv='refresh' content='1;url=index.php' />";
	echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" />\n";
	echo "</head><body>";
	echo "Регистрация прошла успешно! \n";
	echo "</body></html>";
}else
	{
		// проверка наличия такого пользователя в базе
		$result_user = mysql_query("SELECT * FROM `users` WHERE 1;");
		$count_user = mysql_num_rows($result_user);
		echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\" />\n";
		echo "</head><body>";
		echo "<div class=\"header\"><img src=\"img/ball.gif\" alt=\"Enter\" />Регистрация</div>";
		echo "Зарегистрированно: $count_user <br/>\n";
		echo "<form action=\"registration.php\" method=\"post\"> \n";
			echo "<b>Имя:</b> <br/>\n";
			echo "<input class=\"itext\" type=\"text\" name=\"name\" id=\"name\" maxlength=\"20\"/> <br/>\n";

			echo "<b>Email:</b> <br/>\n";
			echo "<input class=\"itext\" type=\"text\" name=\"mail\" id=\"mail\" maxlength=\"35\"/> <br/>\n";
			
			echo "<b>Пароль:</b> <br/>\n";
			echo "<input class=\"itext\" type=\"text\" name=\"pass\" id=\"pass\" maxlength=\"20\"/> <br/>\n";
			
			echo "<br/> <br/> \n";
			echo "<input class=\"ibutton\" type=\"submit\" value=\"Регистрировать\"/> \n";
		echo "</form> \n";
		echo "	</div>\n";
		echo "</body></html>";
	}
?>