| | |
going mad now mysql db password change fails
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2009
Posts: 70
Reputation:
Solved Threads: 0
PHP Syntax (Toggle Plain Text)
Newbee in php Below is my table and script, I know it should change the password I am using a registration application the password is saved in this manner 1d7d2fcc49f157c0be4456580011a58d469c71b6 I could not make out if this is a md5. I echoed the php, the password i type in the form, it shows different. now you must be thinking i typed the wrong password I can login to the web application with the password but using the same password i cannot change Please advice `users` ( `id` int(255) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(100) NOT NULL, `firstname` varchar(50) DEFAULT NULL, `lastname` varchar(50) DEFAULT NULL, `password` varchar(40) NOT NULL, `active` int(1) NOT NULL DEFAULT '0', `ip` text NOT NULL, `usergroup` text NOT NULL, `datasource_id` int(3) unsigned DEFAULT '0', `last_login` int(14) DEFAULT NULL, `day_limit` int(3) unsigned DEFAULT NULL, `language` varchar(5) NOT NULL DEFAULT 'en', `email` varchar(100) DEFAULT NULL, `pwd_updated` int(14) unsigned DEFAULT NULL, `created` int(14) unsigned NOT NULL DEFAULT '0', `owner_id` int(255) NOT NULL DEFAULT '0', `modified` int(14) unsigned DEFAULT NULL, `updated` int(14) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `login` (`username`), KEY `active` (`active`), KEY `password` (`password`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; /* <? $host="localhost"; // Host name $username="root"; // Mysql username $password="brijpuja1"; // Mysql password $db_name="newsumo"; // Database name $tbl_name="users"; // Table name $username=$_POST['username']; $oldpass=$_POST['oldpass']; $newpass=$_POST['newpass']; $conpass=$_POST['confirmpass']; $encry_oldpass=md5($oldpass); //encrypting old password echo "$encry_oldpass"; /* Test OK echo $username; echo "<br />"; echo $oldpass; echo "<br />"; echo $encry_oldpass; echo "<br />"; die(); */ $con=mysql_connect("$host","$username","$password"); mysql_select_db("$db_name",$con); $result=mysql_query("SELECT * FROM $tbl_name WHERE username='$username' and password='$encry_oldpass'"); $count=mysql_num_rows($result); if((!empty($newpass)&&!empty($conpass))&&($newpass==$conpass)&&($count==1)) { $encry_conpass=md5($conpass);//encrypting confirm password $result2=mysql_query("UPDATE $tbl_name SET password='$encry_conpass' WHERE username='$username' and password='$encry_oldpass'"); echo "Password Chamged Successfully"; //header("location:..............."); // redirect to login page } else { echo"Password Change Fails"; //header("location:..............."); // redirect to password change page } ?> */
Last edited by j_limboo; Oct 15th, 2009 at 9:48 pm.
0
#2 Oct 16th, 2009
This section is commented out:
But I think you need it to connect to the database and retrieve the details from the form. You should also validate all $_POST variables.
Also, you set $username to "root", then overwrite it with $_POST["username"]. You need to make sure they are different variables.
php Syntax (Toggle Plain Text)
<? $host="localhost"; // Host name $username="root"; // Mysql username $password="brijpuja1"; // Mysql password $db_name="newsumo"; // Database name $tbl_name="users"; // Table name $username=$_POST['username']; $oldpass=$_POST['oldpass']; $newpass=$_POST['newpass']; $conpass=$_POST['confirmpass']; $encry_oldpass=md5($oldpass); //encrypting old password echo "$encry_oldpass";
Also, you set $username to "root", then overwrite it with $_POST["username"]. You need to make sure they are different variables.
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. ![]() |
Similar Threads
- how to create a password and change the password? (C++)
- Password change md5 in mysql problem (PHP)
- Alert and Force Password Change every 3 months (ASP)
- Deleting multiple rows from mysql with checkbox (PHP)
- Apache (Linux Servers and Apache)
- can i use mysql database with asp (ASP)
- MySql Labyrinth (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Ping
- Next Thread: How can I code an included template to appear only on two pages?
| Thread Tools | Search this Thread |
advanced apache api array beginner binary broken cakephp checkbox class cms code cookies cron curl database date datepart display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google head href htaccess html if...loop image include includingmysecondfileinthechain insert ip javascript job joomla jquery key library limit link login mail menu mlm multiple mysql oop password paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search server sessions smarty sms soap sorting source space sql startup stored syntax system table traffic tutorial update upload url validator variable video web xml youtube zend





