Ciao ecco l'ho fatto
<?php
if (isset($_POST['submit'])) {
// Handle the form.
require_once ('manageme.php');
// Connect to the db.
// Create a function for escaping the data.
function escape_data ($data) {
global $db; // Need the connection.
if (ini_get('magic_quotes_gpc')) {
$data = stripslashes($data);
}
mysql_connect($db['host'],$db['user'],$db['pass']);
mysql_select_db($db['name']);;
}
// End of function.
$message = NULL; // Create an empty new variable.
// Check for a loginName.
if (empty($_POST['loginName'])) {
$lo = FALSE;
$message .= '
You forgot to enter your Login Name!</p>';
} else {
$lo = escape_data($_POST['loginName']);
}
// Check for an existing password.
if (empty($_POST['password'])) {
$pa = FALSE;
$message .= '
You forgot to enter your existing password!</p>';
} else {
$pa = escape_data($_POST['password']);
}
// Check for a password and match against the confirmed password.
if (empty($_POST['password1'])) {
$npa = FALSE;
$message .= '
You forgot to enter your new password!</p>';
} else {
if ($_POST['password1'] == $_POST['password2']) {
$npa = escape_data($_POST['password1']);
} else {
$npa = FALSE;
$message .= '
Your new password did not match the confirmed new password!</p>';
}
}
if ($lo && $pa && $npa) { // If everything's OK.
$query = "SELECT id FROM tablename WHERE (loginName='".$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 tablename SET password=PASSWORD('$npa') WHERE id=$row[0]";
$result = mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
// Send an email, if desired.
echo '
Your password has been changed.</p>';
exit(); // Quit the script.
} else { // If it did not run OK.
$message = '
Your password could not be changed due to a system error. We apologize for any inconvenience.</p>
' . mysql_error() . '</p>';
}
} else {
$message = '
Your loginName and password do not match our records.</p>';
}
mysql_close(); // Close the database connection.
} else {
$message .= '
Please try again.</p>';
}
} // End of the main Submit conditional.
// Print the error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
?>
Però gli errori non me li da più ma mi da sempre
You forgot to enter your Login Name!
Please try again.
e non mi cambia password cosa manca???