blink359 Posted May 4, 2009 Author Share Posted May 4, 2009 Dont need to remove user + pass its included in config.php <?php include('config.php'); mysql_connect($dbhost, $dbuser, $dbpass); mysql_select_db($dbname); $success = true; $problemMessage = ""; if (isset($_POST['Submit'])) { $user = isset($_POST['user'])?$_POST['user']:false; $pass = isset($_POST['pass'])?$_POST['pass']:false; $pass2 = isset($_POST['newpass'])?$_POST['pass2']:false; $pass2 = isset($_POST['newpass2'])?$_POST['pass2']:false; if(!$user || !$pass ||!$newpass || !$newpass2); { $problemMessage = "Please fill in all required data"; $success = false; } if($newpass != $newpass2) { $problemMessage .= "Your passwords do not match <br />"; $success = false; } if(strlen($newpass2) < 5) { $problemMessage .= "Your password must be more than 5 characters<br />"; $success = false; } if(strlen($newpass2) > 20) { $problemMessage .= "Your password cannot be longer than 20 characters <br />"; $success = false; } $result = mysql_query("SELECT * FROM `accounts` where login='$user' AND password='$pass'") or die(mysql_error()); { if (empty($result)) return 'Invalid username or password'; else { $sql = "UPDATE accounts SET password = '$newpass' WHERE username = '$user' and password = '$pass';"; $result = mysql_query($sql); if (empty($result)) return mysql_error(); } ?> <html> <head> <title>Password Change</title> </head> <body <form action="" method="post" Username: <input type="text" name="user"> <br> Password: <input type="password" name="pass"> <br> New Password: <input type="password" name="newpass"> <br /> Repeat New Password: <input type="password" name="newpass2"> <br /> <input name="Submit" type="submit" value="submit"> <imput name="reset" type="reset" value="reset"> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/156807-quick-mysql-query-problem/page/2/#findComment-825956 Share on other sites More sharing options...
Ken2k7 Posted May 4, 2009 Share Posted May 4, 2009 Oh... First, see my "return" words? Change that word to "$problemMessage .= " You probably want to update the $success variable as well. Then before "?>" add "}" Link to comment https://forums.phpfreaks.com/topic/156807-quick-mysql-query-problem/page/2/#findComment-825960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.