вот код:
index.php
<html>
<head><?
include ('connectdb.php');
include ('functions.php');
?>
<?
if($_POST['reg']){
$login=$_POST['login'];
$password=$_POST['password'];
$firstname=$_POST['firstname'];
$surname=$_POST['surname'];
echo reg($login, $password);
}
?>
<link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css" media="screen" title="no title" charset="utf-8" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/jquery.validationEngine.js" type="text/javascript"></script>
x
<title>
<?
echo getnamebyid('name').' '.getnamebyid('surname')
?>
</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="stylesheet" type="text/css" href="userpage.css" />
</head>
<body>
<div id='menu'>
<?
if(!$_COOKIE['login'] || !$_COOKIE['password']){
echo '<form method="post" action=\'index.php\'>
<span id=\'typeofreg\'></span>
<input class="validate[required,custom[email]] text-input" name=\'login\' placeholder=\'E-mail\'><br>
<input class="validate[required,length[6,11]] text-input" type=\'password\' name=\'password\' placeholder=\'Пароль\'><br>
<input class="validate[required,custom[onlyLetter],length[0,100]] text-input" name=\'firstname\' placeholder=\'Имя\'><br>
<input class="validate[required,custom[onlyLetter],length[0,100]] text-input" name=\'surname\' placeholder=\'Фамилия\'><br>
<input name=\'reg\' value=\'Зарегистрироваться\' type=submit>
</form>
';
}
?>
</div>...
и functions.php
...
function reg($login, $password){
$login = stripslashes($login);
$login = htmlspecialchars($login);
$password = stripslashes($password);
$password = htmlspecialchars($password);
$login = trim($login);
$password = trim($password);
$firstname = stripslashes($firstname);
$firstname = htmlspecialchars($firstname);
$surname = stripslashes($surname);
$surname = htmlspecialchars($surname);
$firstname = trim($firstname);
$surname = trim($surname);
include ('connectdb.php');
$result = mysql_query("SELECT id FROM users WHERE email='$login'");
$myrow = mysql_fetch_array($result);
if (empty($myrow['id'])) {
$password = md5($password);
$result2 = mysql_query ("INSERT INTO users (email,password,name,surname) VALUES('$login','$password','$firstname','$surname')");
setcookie ("login", "$login", time() + 3600);
setcookie ("password", "$password", time() + 3600);
}
else{
$return = "Извините, введённый вами логин уже зарегистрирован. Введите другой логин.";
}
return $return;
}
?>