Jump to content

Can't check from database and update.


Garloz

Recommended Posts

Hi,

sorry for disturbing. I have tried some ways, but I can't figure it out. I have the following code in my PHP file. It does'nt take(check) username and password from database.. But I want that it will do. I copied it from another website, so.. it's not my code. But I need it :( Something musst be wrong on this..

 

$query = "SELECT id FROM testtable WHERE (username='$lo' AND password=password('$pa') )";
$result = @mysql_query ($query);
$num = mysql_num_rows ($result);
if ($num == 1) {
$row = mysql_fetch_array($result, mysql_NUM);

// Make the query.
$query = "UPDATE testtable SET password=password('$npa') WHERE id=$row[0]";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
echo '<p><b>Your password has been changed.</b></p>';

Link to comment
https://forums.phpfreaks.com/topic/197243-cant-check-from-database-and-update/
Share on other sites

Try this...

 

$query = "SELECT * FROM testtable WHERE username='$lo' AND password=password('$pa')";
$result = @mysql_query ($query);
$num = mysql_num_rows ($result);
if ($num == 1) {
$row = mysql_fetch_object($result);

// Make the query.
$query = "UPDATE testtable SET password=password('$npa') WHERE id='$row->id'";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
   echo '<p><b>Your password has been changed.</b></p>';

 

:confused:

Don't be too sure about my response... :P I can

 

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.