everything is fine until everything is right...
Posted: Thu Sep 24, 2009 10:23 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Im trying to create a register page for my web site, coded it to the best of my ability and below is what I got. If info is missing, I get the missing info error, if the user name is taken, I get the user name taken error, and if the passwords do not match, I get that error. Unfortunately, if everything is right, I get a black page! Any help would be greatly appreciated!
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Im trying to create a register page for my web site, coded it to the best of my ability and below is what I got. If info is missing, I get the missing info error, if the user name is taken, I get the user name taken error, and if the passwords do not match, I get that error. Unfortunately, if everything is right, I get a black page! Any help would be greatly appreciated!
Code: Select all
<?php
session_start();
require("config.php");
require("db.php");
if($_POST['submit'])
{
if(empty($_POST['username']) ||
empty($_POST['username']) ||
empty($_POST['username'])){
header("Location: " . $config_basedir . "register.php?error=1");
exit;
}
$_SESSION['username'] = $_POST['username'];
if($_POST['password1'] == $_POST['password2'])
{
$checksql = "SELECT * FROM logins WHERE username = '" . $_POST['username'] . "';";
$checkresult = mysql_query($checksql) or die(mysql_error());
$checknumrows = mysql_num_rows($checkresult) or die(mysql_error());
if($checknumrows != 1)
{
header("Location: " . $config_basedir . "cust-address.php");
exit;
}else{
header("Location: " . $config_basedir . "register.php?error=taken");
exit;
}
}else{
header("Location: " . $config_basedir . "register.php?error=2");
exit;
}
}
require("header.php");
if(($_GET['error']) == 1){
echo "<strong>Please fill in the missing information from the form</strong>";
}elseif(($_GET['error']) == 'taken'){
echo "<strong>User name already taken</strong>";
}elseif(($_GET['error']) == 2){
echo "<strong>Passwords do not match</strong>";
}
?>
<h2>Register</h2>
<form action="<?php echo $SCRIPT_NAME ?>" method="post">
<table border="1" cellpadding="5">
<tr>
<td><strong>User Name</strong></td>
<td><input type="text" name="username" value="<?php echo $_SESSION['username'] ?>"></td>
<td><strong>Password</strong></td>
<td><input type="password" name="password1"></td>
</tr>
<tr>
<td colspan = "2"></td>
<td><strong>confirm password</strong></td>
<td><input type="password" name="password2"></td>
</tr>
<tr>
<td colspan="4"><div align="center"><input type="submit" name="submit" value="Register"></div></td>
</tr>
</table>
</form>
<?php
require("footer.php");
?>pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: