|
-
Jul 20th, 2004, 09:01 PM
#1
Thread Starter
PowerPoster
Variable Reset After Query
I'm learning PHP as I go so please bar with me.
I've set up a registration form for our website and everything works fine. I've now added a check to see if the User Name entered is already taken. The problem is if the registration is successful the User Name field comes through blank in the confirmation email. If I take out the check for duplicate User Names the field is not blank.
Can anyone help me out?
Thanks.
PHP Code:
//Check if user name is alrady taken.
$query_l = "SELECT * from ebook_users WHERE username = '$uname'";
$l_check = mysql_query($query_l);
$check = mysql_fetch_row($l_check);
if ($uname = $check[5]) {
include 'registration2.php';
exit;
}
// starting registration [sending verification email]
include("mojt_db.php");
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: [email][email protected][/email]";
$body = "*****************************************************
<br>
Hi $ufname,
<p>
\n\nTo activate your account please <a href=\"$SiteUrl/$MojtDir/index.php?substr=registration&ufname=$ufname&ulname=$ulname&uemail=$uemail&uicq=$uicq&uwsite=$uwsite&uname=$uname&upass=$upass\">click here</a> to verify your email address.
<p>
Regards,
<p>
\n$SiteName Team.
<br>
*****************************************************";
mail($uemail, "Confirmation Email", $body, $headers);
-
Jul 21st, 2004, 03:27 AM
#2
Heres your probelm: if ($uname = $check[5])
This assigns the value of $check[5] to $uname. If this is blank then $uname will be blank. You need to use the equality operator rather than the assignment opertator:
This should work:
PHP Code:
if ($uname == $check[5])
....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|