registration submit button dont work also w/ variable error
Posted: Tue Jun 14, 2005 11:44 pm
a simple registration form
when i load this from a web page, it does nothing when i press the submit button. i tried to use it at home on a winxp pro w/ php-5 and mysql and i edited the php.ini file
so i could see more errors (i unquote the line thats shows all kinds of errors and notification) then i saw it has some unidentified variable error on some lines.
edit: i also turned on the register globals to make sure but it still dont work
when i load this from a web page, it does nothing when i press the submit button. i tried to use it at home on a winxp pro w/ php-5 and mysql and i edited the php.ini file
so i could see more errors (i unquote the line thats shows all kinds of errors and notification) then i saw it has some unidentified variable error on some lines.
edit: i also turned on the register globals to make sure but it still dont work
Code: Select all
<?php
if(isset($_POST['submit'])){
//handle the form.
$submit = $_POST['submit'];
$message = NULL; //create a variable
//check for a username
if (empty($_POST['username']))
{$un = FALSE;
$message .= '<p>You forgot to enter your user name</p>';
}else{
$un = $POST['username'];
}
//check for a password and match against the confirmed password
if (empty($_POST['password1']))
{$p = FALSE;
$message .= '<p>You forgot to enter a password!</p>';
}else{
if ($_POST['password1'] == $_POST['password2'])
{$pw = $POST['password1'];
}else{
$pw=FALSE;
$message .= '<p>Your password did not match the confirmed password!</p>';
}
}
//check for a email
if (empty($_POST['email']))
{$em = FALSE;
$message .= '<p>You forgot to enter your email</p>';
}else{
$em = $POST['email'];
}
if($un && $pw && $em)
{//if the three inputs have value
require_once('/mysql_connect.php'); //connect to database
$query = "INSERT INTO forum_users (u_nick, u_password, u_email, u_date) VALUES ('$un',PASSWORD('$pw'),'$em','NOW())";
$result = @mysql_query($query); //run the query
if($result) {//if it ran ok
echo '<p>You are now registered.</p>';
exit();
}else{//something is missing
$message = '<p>error</p><p>'.mysql_error().'</p>';
}
mysql_close();
}else{ $message .='<p>Please try again.</p>';
echo('$un' . "$un");
}
}
if(isset($message)){
echo '<font color="red">',$message,'</font>';
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>ENTER YOUR INFORMATION IN THE FORM BELOW:</legend>
<p><b>User Name:</b> <input type="text" name="username" size="15" maxlength="15"
value="<?php if(isset($_POST['username'])) echo $POST['username'];?>"/></p>
<p><b>Password:</b> <input type="password" name="password1" size="20" maxlength="40"
value="<?php if(isset($_POST['password1'])) echo $POST['password1'];?>"/></p>
<p><b>Confirm Password:</b> <input type="password" name="password2" size="20" maxlength="40"
value="<?php if(isset($_POST['password2'])) echo $POST['password2'];?>"/></p>
<p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="60"
value="<?php if(isset($_POST['email'])) echo $POST['email'];?>"/></p>
</fieldset>
<div align="center"><input type="submit" name="submit" value="Register"/>
</div>
</form>