Hi,
I am working on this big project (at least big for me) and writing a user-registration form. While looking around, I saw Tim Perdue's complete snippet functions on user-authorization and said "why not use it". So I'm using it and it is failing, just as did MY OWN code fail in checking the user input before doing anything. Let me get to the business, though. So below is the code and I it is not passing through the second IF statement. My form elements are all in an array called REGISTER. So user's desired username will be located in $register[username]. For more code, visit http://photography.vevi.net
<?
include stuff...
include other stuff...
print "Step1";
//all vars present and passwords match?
if (isset($register[username]) && !empty($register[username]) && isset($register[password]) &&
!empty($register[password]) && ($register[password] == $register[password2]) && isset($register[email]) &&
!empty($register[email]) && validate_email($register[email]))
{
print "OK, We're in";
//password and name are valid?
if (account_namevalid($register[username]) && account_pwvalid($register[password])) {
$username=strtolower($register[username]);
$password1=strtolower($register[password]);
//does the name exist in the database?
$sql="SELECT * FROM users WHERE username='$register[username]'";
$result=db_query($sql);
if ($result && db_numrows($result) > 0) {
$error_message .= ' ERROR - USER NAME EXISTS ';
} else {
//create a confirmation code to insert into the db and the confirmation email
$confirmation_code = md5(rand(1,999999999999999));
//Create today's date.
$date = date('Y-m-d H:i:s');
//Define the SQL query.
$sql="INSERT INTO users (username,password,fname,lname,gender,age,email,city,country,state,date,confirmation_code) ".
"VALUES ('$register[username]','$register[password]','$register[fname]','$register[lname]','$register[gender]',
'$register[age]','$register[email]','$register[city]','$register[country]','$register[state]','$date','$confirmation_code')";
$result=db_query($sql);
if (!$result) {
$error_message .= ' ERROR - '.db_error();
} else {
//send the confirm email
user_send_confirm_email($email,$confirmation_code);
$error_message .= 'Succesfully completed step 1. Please check your e-mail for instructions to complete your registration process.';
print "I'm done (just checking)";
}
}
} else {
$error_message .= 'Account Name or Password Invalid ';
}
} else {
$error_message .= ' ERROR - Must Fill In User Name, Matching Passwords, And Provide Valid Email Address ';
}
If there's anyone who can shed some light over this issue, please help me out. I'll acknowledge you in the Credits section (which will be up soon) :-)
Ilir.