Page 1 of 1

Resource as conditional

Posted: Sat Sep 20, 2008 12:03 am
by iG9
Hi. I'm writing a registration / email validation script. The registration form generates the validation string and stores it in the MySQL table in the user's tuple. The part that's giving me issues is the validation page. The user follows an email link to a page that asks for his email and validation code. It's supposed to check that the pair entered matches the tuple and if so update the "validated" column to "YES", but it doesn't work. I think in might have to do with my not accessing the resource properly, but try looking up "accessing php resource" on the web.
Hahaha.

Code: Select all

   /***Check input & update table or give error***/
    $query = "select val_string from $table_name where email = \"$_POST[email]\"";
    $result = mysql_query($query);
    if ($result->val_string == $_POST['val_string']) {
        $update_user = "update $table_name set validated = \"YES\" where email = $_POST[email] && val_string = $_POST[val_string]";
        mysql_query($update_user);
        echo "Success! Feel free to login.";
    } else {
        echo "Sorry, please try again.";
    }
 
It always goes to the else. Any ideas?

Re: Resource as conditional

Posted: Sat Sep 20, 2008 12:11 am
by s.dot
Your result is still a mysql resource. You can use $data = mysql_fetch_assoc($result); if ($data['val_string'] == $_POST['val_string']){ // }

Re: Resource as conditional

Posted: Sat Sep 20, 2008 11:45 am
by iG9
Thanks man that worked like a charm. :mrgreen: