Jump to content

Problem with UPDATE to table


matt_jo84

Recommended Posts

I have been having problems with updating a table of mine for the past few days and cannot find a solution or reason why it is not working. What happens with the code below is a user logs in so an query is made to update their login status to 1 (0 = logged out, 1 = logged in). Then to make sure that the update to the database is made there is a check to see if it has been changed to 1 before the page is redirected to logged_IN.htm (the code below does find $login_num = 1). The problem is that in the table after the header function is executed. The value for login never changed to 1 in the table, it is always still 0. If I remove the header and have it not redirect to another page the login value in the table does change to 1. I have tried using 2 different servers also and still have no luck. Please help me out if you can, thanks.

 

 

mysql_query("UPDATE " . $table . " SET login = '1' WHERE password = '$pass'");

$query_login = mysql_query("SELECT login FROM " . $table . " WHERE password = '$pass' ");

$login_num = mysql_result($query_login, 0);

 

if($login_num == '1')

{

header( "Location: http://www.website.com/logged_IN.htm" );

}

Link to comment
https://forums.phpfreaks.com/topic/43167-problem-with-update-to-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.