The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsParse error: syntax error, unexpected $end in C:\wamp\www\register\register.php on line 131
I got that error after making a registration:
I have a function.php
& a register.php
<?php
include_once "functions.php";
connect();
if(!$_POST['submit']){
echo "<tabel border-\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<form method=\"post\" action=\"register.php\">\n";
echo "<tr><td colspan=\"2\" align=\"center\">Registration Form</td></tr>\n";
echo "<tr><td> Username</td><td><input type=\"text\" name=\"username\"></td></tr>\n";
echo "<tr><td> Password</td><td><input type=\"password\" name=\"password\"></td></tr>\n";
echo "<tr><td> Confirm</td><td><input type=\"password\" name=\"passconf\"></td></tr>\n";
echo "<tr><td> E-mail</td><td><input type=\"text\" name=\"email\"></td></tr>\n";
echo "<tr><td> Name</td><td><input type=\"text\" name=\"name\"></td></tr>\n";
echo "<tr><td> AIM Address</td><td><input type=\"text\" name=\"aim\"></td></tr>\n";
echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Register\"></td></tr>\n";
echo "</form></table>\n";
}else {
$username = protect($_POST['username']);
$password = protect($_POST['password']);
$confirm = protect($_POST['passconf']);
$email = protect($_POST['email']);
$name = protect($_POST['name']);
$aim = protect($_POST['aim']);
$errors = array();
if(!$username){
$errors[] = "Username is not defined!";
}
if(!$password){
$errors[] = "Password is not defined!";
}
if(!$username){
if(!confirm){
$errors[] = "Confirmation password is not defined";
}
}
if(!$email){
$errors[] = "E-mail is not defined!";
}
if(!$name){
$errors[] = "Name is not defined";
}
if(!$aim){
$errors[] = "AIM is not defined!";
}
if($username){
if(!ctype_alnum($username)){
$errors[] = "Username can only contain numbers and letters!";
}
$range = range(1,32);
if(!in_array(strlen($username),$range)){
$errors[] = "Username must be between 1 and 32 characters!";
}
}
if($password && $confirm){
if($password != $confirm){
$errors[] = "Passwords do not match!";
}
}
if($email){
$checkemail = "/^[a-x0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i";
if(!preg_match($checkemail, $email)){
$errors[] = "E-mail is not valid, must be name@server.tld!";
}
}
if($name){
$range2 = range(3,64);
if(!in_array(strlen($name),$range2)){
$errors[] = "Your name must be between 3 and 64 characters";
}
}
if($aim){
$range3 = range(3,16);
if(!in_array(strlen($aim),$range3)){
$errors[] = "Your AIM screenname must be between 3 and 16 characters!";
}
}
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 supplied is already in use!";
}
}
if($email){
$sql2 = "SELECT * FROM `users` WHERE `username`='{$email}'";
$res2 = mysql_query($sql2) or die(mysql_error());
if(mysql_num_rows($res2) > 0)
$errors[] = "The email is already in use";
}
if($aim){
$sql3 = "SELECT * FROM `users` WHERE `username`='{$aim}'";
$res3 = mysql_query($sql3) or die(mysql_error());
if(mysql_num_rows($res3) > 0)
$errors[] = "The AIM is already in use";
}
if(count($errors) > 0){
foreach($errors AS $error)
echo $error . "<br>\n";
}
else {
$sql4 = "INSERT INTO `users`
(`username`,`password`,`email`,`name`,`aim`)
VALUES('$username','".md5($password)."','$email','$name','$aim')";
$res4 = mysql_query($sql4) or die(mysql_error());
echo "You suck!;
}
}
?>
functions:
<?php
function protect($string){
$string = mysql_real_escape_string($string);
$string = strip_tags($string);
$string = addslashes($string);
return $string;
}
function connect(){
$con = mysql_connect(localhost, root, '') or die(mysql_error());
$db = mysql_select_db(users, $icon);
}
?> "My software never has bugs. It just develops random features. " - Unknown
[ FluxBB developer | Quickmarks 0.5.1 | Strings & Ints - my blog ]