sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 If anyone else can pitch in to help that would be great. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647934 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 forgot to mention, you need this $host="localhost"; // Host name $username="bucketho_***"; // Mysql username $password="****"; // Mysql password $db_name="bucketho_****"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); at the top of the page. also, make sure you set the password for your mysql connection info. Â That's what the error is saying. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647935 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Just like that? Â Where do I add the { } things... Â <?php session_start(); $host="localhost"; // Host name $username="bucketho_***"; // Mysql username $password="****"; // Mysql password $db_name="bucketho_****"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if ($_GET['change_pass'] == true){ $new_pass1 = mysql_real_escape_string($_POST['pass1']); $new_pass2 = mysql_real_escape_string($_POST['pass2']); $old_pass = mysql_real_escape_string($_POST['old_pass']); $username = $_SESSION['username']; $sql = "SELECT * FROM `members` WHERE `username`='$username' AND `password`='$old_pass' LIMIT 1;"; $results = mysql_query($sql); $count_res = mysql_num_rows($sql); if (($count_res == 1) && ($new_pass1 == $new_pass2)){ $sql = "UPDATE `members` SET `password`='$new_pass1' WHERE `username`='$username';"; mysql_query($sql); header("location:./"); exit(); } else{ print "Error processing Password change. Please try again"; } } if ($_GET['pass_change_form'] == true){ ?> <form method="POST" action="?change_pass=true"> <table border="0"> <tr> <td>Old Password:</td> <td><input type="password" name="old_pass"></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="pass1"></td> </tr> <tr> <td>New Password(Again):</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td>Â </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <?php } Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647937 Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 I don't think you need them... Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647938 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Another error  Parse error: syntax error, unexpected T_LNUMBER in /home/bucketho/public_html/admin/change_password.php on line 6  I guess the saying "Third times the charm" doesnt apply here...  Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647940 Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 Sorry I haven't totally been following your thread, could you post your code so I can CnP to view the line numbers? Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647946 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 You want the code that I have currently for change_Password.php?  Here:  <?php session_start(); $host="localhost"; // Host name $username="bucketho_****; // Mysql username $password="*****"; // Mysql password $db_name="bucketho_****"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); if ($_GET['change_pass'] == true){ $new_pass1 = mysql_real_escape_string($_POST['pass1']); $new_pass2 = mysql_real_escape_string($_POST['pass2']); $old_pass = mysql_real_escape_string($_POST['old_pass']); $username = $_SESSION['username']; $sql = "SELECT * FROM `members` WHERE `username`='$username' AND `password`='$old_pass' LIMIT 1;"; $results = mysql_query($sql); $count_res = mysql_num_rows($sql); if (($count_res == 1) && ($new_pass1 == $new_pass2)){ $sql = "UPDATE `members` SET `password`='$new_pass1' WHERE `username`='$username';"; mysql_query($sql); header("location:./"); exit(); } else{ print "Error processing Password change. Please try again"; } } if ($_GET['pass_change_form'] == true){ ?> <form method="POST" action="?change_pass=true"> <table border="0"> <tr> <td>Old Password:</td> <td><input type="password" name="old_pass"></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="pass1"></td> </tr> <tr> <td>New Password(Again):</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td> </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <?php }  and here is the error  http://delta.bluespacetechnologies.com/~bucketho/admin/change_password.php?change_pass=true Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647949 Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 You changed these 2 lines with the real PW and DB name right? lol  $password="*****"; // Mysql password $db_name="bucketho_****"; // Database name   Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647953 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Yes, I just blocked them out for you not to see... Â Â Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647954 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 I did now.  Instead of doing: $username="bucketho_****"; // Mysql username  I did: $username="bucketho_****; // Mysql username  I left out the "  Now there is a new error.   Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647959 Share on other sites More sharing options...
Maq Posted September 22, 2008 Share Posted September 22, 2008 No, you need that quote in there. Change this line to this:  mysql_connect($host, $username, $password)or die("cannot connect");  Don't need the quotes because these values are all ready strings. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647961 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 This is what i have for now: Â change_password.php <?php session_start(); $host="localhost"; // Host name $username="bucketho_****"; // Mysql username $password="****"; // Mysql password $db_name="bucketho_****"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB"); if ($_GET['change_pass'] == true){ $new_pass1 = mysql_real_escape_string($_POST['pass1']); $new_pass2 = mysql_real_escape_string($_POST['pass2']); $old_pass = mysql_real_escape_string($_POST['old_pass']); $username = $_SESSION['username']; $sql = "SELECT * FROM `members` WHERE `username`='$username' AND `password`='$old_pass' LIMIT 1;"; $results = mysql_query($sql); $count_res = mysql_num_rows($sql); if (($count_res == 1) && ($new_pass1 == $new_pass2)){ $sql = "UPDATE `members` SET `password`='$new_pass1' WHERE `username`='$username';"; mysql_query($sql); header("location:./"); exit(); } else{ print "Error processing Password change. Please try again"; } } if ($_GET['pass_change_form'] == true){ ?> <form method="POST" action="?change_pass=true"> <table border="0"> <tr> <td>Old Password:</td> <td><input type="password" name="old_pass"></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="pass1"></td> </tr> <tr> <td>New Password(Again):</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td>Â </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <?php } Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647963 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Any luck? Â This is turning out to be a real pain in the butt. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647967 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 Sorry, was busy (at work). OK, back now. Lets do this line for line: <?php session_start(); $host = "localhost"; // Host name $username = "bucketho_****"; // <-- Mysql username MAKE SURE THIS IS SET! $password = "****"; // <-- Mysql password MAKE SURE THIS IS SET! $db_name = "bucketho_****"; // <-- Database name CHANGE THIS TOO! $tbl_name = "members"; // Table name // Connect to server and select databse. mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB"); if ($_GET['change_pass'] == true){ $new_pass1 = mysql_real_escape_string($_POST['pass1']); $new_pass2 = mysql_real_escape_string($_POST['pass2']); $old_pass = mysql_real_escape_string($_POST['old_pass']); $username = $_SESSION['username']; $sql = "SELECT * FROM `members` WHERE `username`='$username' AND `password`='$old_pass' LIMIT 1;"; $results = mysql_query($sql); $count_res = mysql_num_rows($sql); if (($count_res == 1) && ($new_pass1 == $new_pass2)){ $sql = "UPDATE `members` SET `password`='$new_pass1' WHERE `username`='$username';"; mysql_query($sql); header("location:./"); exit(); } else{ print "Error processing Password change. Please try again"; } } if ($_GET['pass_change_form'] == true){ ?> <form method="POST" action="?change_pass=true"> <table border="0"> <tr> <td>Old Password:</td> <td><input type="password" name="old_pass"></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="pass1"></td> </tr> <tr> <td>New Password(Again):</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td>Â </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <?php } If you do not correctly set your DB connection info, you'll get the errors you are receiving. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647969 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 There is still an error.  http://delta.bluespacetechnologies.com/~bucketho/admin/change_password.php?change_pass=true  Do you need any other information? Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647970 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Sorry about bothering you while you are at work. Â Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647973 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 found the error <?php session_start(); $host = "localhost"; // Host name $username = "bucketho_****"; // <-- Mysql username MAKE SURE THIS IS SET! $password = "****"; // <-- Mysql password MAKE SURE THIS IS SET! $db_name = "bucketho_****"; // <-- Database name CHANGE THIS TOO! $tbl_name = "members"; // Table name // Connect to server and select databse. mysql_connect($host, $username, $password)or die("cannot connect"); mysql_select_db($db_name)or die("cannot select DB"); if ($_GET['change_pass'] == true){ $new_pass1 = mysql_real_escape_string($_POST['pass1']); $new_pass2 = mysql_real_escape_string($_POST['pass2']); $old_pass = mysql_real_escape_string($_POST['old_pass']); $username = $_SESSION['username']; $sql = "SELECT COUNT(*) AS `total_found` FROM `members` WHERE `username`='$username' AND `password`='$old_pass' LIMIT 1;"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $total_found = $row['total_found']; if (($total_found == 1) && ($new_pass1 == $new_pass2)){ $sql = "UPDATE `members` SET `password`='$new_pass1' WHERE `username`='$username';"; mysql_query($sql); header("location:./"); exit(); } else{ print "Error processing Password change. Please try again"; } } if ($_GET['pass_change_form'] == true){ ?> <form method="POST" action="?change_pass=true"> <table border="0"> <tr> <td>Old Password:</td> <td><input type="password" name="old_pass"></td> </tr> <tr> <td>New Password:</td> <td><input type="password" name="pass1"></td> </tr> <tr> <td>New Password(Again):</td> <td><input type="password" name="pass2"></td> </tr> <tr> <td>Â </td> <td><input type="submit" value="Submit"></td> </tr> </table> </form> <?php } That's what happens when you're coding in a hurry. sry about the mix up. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647974 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 That is the new updated one correct? Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647976 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 Ok, now there is no error, but just says this. Â http://delta.bluespacetechnologies.com/~bucketho/admin/change_password.php?change_pass=true Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647977 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 yup. forgot to use $result for the number, and used $sql instead. oops. Well, I changed the query, to make it faster, so you shouldn't have any further issues. Â As for the new error, that means that 1: the username and password doesn't match up with what is in the database, or 2: the new passwords don't match up. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647979 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 No I mean that even when I load the page, it wont even show the change password script. Â Can you re post the updated change_password.php script. Â Thanks... Â Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647980 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 don't forget: change the password using the form: http://delta.bluespacetechnologies.com/~bucketho/admin/change_password.php?pass_change_form=true Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647981 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 I tried to change my password. It still wont work... Â The password I am using I know is correct. Â Â Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647983 Share on other sites More sharing options...
jonsjava Posted September 22, 2008 Share Posted September 22, 2008 one sec. re-creating your environment on my sandbox. Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647984 Share on other sites More sharing options...
sith717 Posted September 22, 2008 Author Share Posted September 22, 2008 I am getting really mad... Â Lol... Link to comment https://forums.phpfreaks.com/topic/125341-solved-change-password/page/2/#findComment-647985 Share on other sites More sharing options...
Recommended Posts