Forum Moderators: coopster
<?php
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');
require_once('../includes/Validator.php');
require_once("../includes/Sentry.php");
// Create an instance of DbConnector
$connector = new DbConnector();
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
// Validate the entries
$validator = new Validator();
// Check whether the validator found any problems
if ( $validator->foundErrors() ){
echo 'There was a problem with: <br>'.$validator->listErrors('<br>'); // Show the errors, with a line between each
}else{
// Create an SQL query (MySQL version)
// The 'addslashes' command is used 5 lines below for added security
// Remember to use 'stripslashes' later to remove them (they are inserted in front of any
// special characters
$insertQuery = "UPDATE $cmsusers (pass) VALUES ('$pass') WHERE 'id' = $user";
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
echo '<center><b>Password changed successfully</b></center><br>';
}else{
// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database</center>');
}
}
}
?>
Thanks
$insertQuery = "UPDATE $cmsusers (pass) VALUES ('$pass') WHERE 'id' = $user";
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
So it should be -
$insertQuery = "UPDATE $cmsusers SET pass=$pass WHERE 'id' = $user";