include_once “functions.php”;
connect()
if(!$_POST[‘submit’]){
echo “<table border=“0” cellspacing=“3” cellpadding"3”>\n";
echo “<form method=“post” action=“register.php”>\n”;
echo “
echo “
echo “
echo “
echo “
echo “
echo “\n”;
}else {
$username = protect($_POST[‘username’]);
$password = protect($_POST[‘password’]);
$confirm = protect($_POST[‘passconf’]);
$email = protect($_POST[‘email’]);
$error = array();
if(!$username){
!$errors[] = "Username is not defined!";
}
if(!$password){
!$errors[] = "Password is not defined!";
}
if(!$password){
if(!$confirm) {
!$errors[] = "Confirm passowrd is not defined!";
}
}
if(!$email){
!$errors[] = "E-mail is not defined!";
}
if($username){
if(!ctype_alnum($username)){
$errors[] = "Username can only contains letters and numbers!";
}
}
if($password && confirm){
if($password != $confirm){
$errors[] = "Passwords do not match!";
}
}
if($email){
$checkemail = "/^[a-z0-9]+([_\\.-][a-z0-9]+)@([a-z0-9]+([/.-][a-z0-9]+)*)+\\.[a-z](2,)$/i";
if (!preg_match($email, $checkemail)){
$errors[] = "E-mail is not valid, [email protected]!";
}
}
if($username){
$sql = "SELECT * FROM 'Users' WHERE 'username' = '($username)'";
$res = mysql_query($sql) or die(mysql_error);
if(mysql_num_rows($res) > 0){
$errors[] = "The username you have entered is already taken!";
}
}
if($email){
$sql2 = "SELECT * FROM 'Users' WHERE 'email'='($email)'";
$res2 = mysql_query($sql2) or die(mysql_error());
if(mysql_num_rows($res2) > 0){
$errors[] = "This email is already in use!";
}
}
if(count($errors) > 0){
foreach($errors AS $error){
echo error . "<br>\n";
}
}else{
$sql3 = "INSERT INTO 'Users'
('username', 'password', 'email')
VALUES ('$username', '".md5($password)."', '$email');";
$res4 = mysql_query($sql3) or die(mysql_error());
echo "You have successfully registered '<b>($username)</b>'";
}
}
?>
Another problem, where I put connect() I get an error saying it can’t connect.
that’s the website link if you want to test it.