Resource as conditional

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Resource as conditional

Post 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?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: Resource as conditional

Post 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']){ // }
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
iG9
Forum Commoner
Posts: 38
Joined: Fri Jul 18, 2008 2:11 pm

Re: Resource as conditional

Post by iG9 »

Thanks man that worked like a charm. :mrgreen:
Post Reply