Results 1 to 2 of 2

Thread: Variable Reset After Query

  1. #1

    Thread Starter
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    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); 

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    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])
     .... 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width