I made a script for user login and registration, but when I try to register a new user it gives me the error that I need all fields to be filled in. I am pretty sure that I know what is causing the problem, but I don't know how to fix it. Here is my registration page script:I think the specific part is the part that checks for empty fields:PHP Code:<?php
require("config.php");
if ($_POST['submit']) { //Check if form was submitted
$username = clean($_POST['$username']);
$password = clean($_POST['$password']);
$password2 = clean($_POST['$password2']); //Password confirmation
$email = clean($_POST['email']);
$ip = clean($_SERVER['REMOTE_ADDR']); //Get ip of user
$signup = time(); //Time of registration
if (!$username | !$password | !$password2 | !$email) { //If any fields are empty
echo'You must fill out every field! <a href="'.$_SERVER['REQUEST_URI'].'">Back</a>.';
}
else {
if ($password != !$password2) { //If passwords do not match
echo'The passwords did not match! <a href="'.$_SERVER['REQUEST_URI'].'">Back</a>.';
}
else { //Test to see if username is in use
$user_test = "SELECT * FROM `users` WHERE username = '$username'";
$user_test = mysql_query($user_test);
if (mysql_num_rows(username_test) == 1) { //If username is found
echo'The username is already in use. <a href="'.$_SERVER['REQUEST_URI'].'">Back</a>.';
}
else {
$md5pass = md5($password); //Encrypt password
//Query to add data to table
$add = "INSERT INTO `users VALUES ('', '$username', '$md5pass', '$email', '$ip', '$signup')";
mysql_query($add); //Run query
echo'You have successfully registered! <br />';
echo'Use this information to login: <br />';
echo'Username: '.$username.' <br />';
echo'Password: '.$password;
}
}
}
}
else {
require("register_form.php");
}
?>I checked over everything to make sure that all the fields were filled in and names matched, but found no error. The form code that submits to this page is:PHP Code:if (!$username | !$password | !$password2 | !$email) { //If any fields are empty
echo'You must fill out every field! <a href="'.$_SERVER['REQUEST_URI'].'">Back</a>.';
}
The error displayed is the one i specified for if a field is not filled in. I would appreciate any ideas on whats going wrong. thanksPHP Code:<form method="post" action="<?=$_SERVER['REQUEST_URI']?>">
Username:
<br />
<input type="text" name="username">
<br />
Password:
<br />
<input type="password" name="password">
<br />
Confirm Password:
<br />
<input type="password" name="password2">
<br />
E-mail:
<br />
<input type="text" name="email">
<br />
<input type="submit" name="submit" value="Register">
</form>



Reply With Quote


. However, I ran into yet another issue. When I try to login, it just redisplays the login box and says/does nothing. I am really not sure what is causing it to do this, here is the code, hope someone knows:

Bookmarks