<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://script.spoken-tutorial.org/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC4%2FUser-Password-Change-Part-2%2FEnglish</id>
		<title>PHP-and-MySQL/C4/User-Password-Change-Part-2/English - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://script.spoken-tutorial.org/index.php?action=history&amp;feed=atom&amp;title=PHP-and-MySQL%2FC4%2FUser-Password-Change-Part-2%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Password-Change-Part-2/English&amp;action=history"/>
		<updated>2026-05-05T11:13:39Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.23.17</generator>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Password-Change-Part-2/English&amp;diff=906&amp;oldid=prev</id>
		<title>Pravin1389: moved PHP-and-MySQL/C4/User-Password-Change-(Part 2)/English to PHP-and-MySQL/C4/User-Password-Change-Part-2/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Password-Change-Part-2/English&amp;diff=906&amp;oldid=prev"/>
				<updated>2012-12-01T15:57:55Z</updated>
		
		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php/PHP-and-MySQL/C4/User-Password-Change-(Part_2)/English&quot; class=&quot;mw-redirect&quot; title=&quot;PHP-and-MySQL/C4/User-Password-Change-(Part 2)/English&quot;&gt;PHP-and-MySQL/C4/User-Password-Change-(Part 2)/English&lt;/a&gt; to &lt;a href=&quot;/index.php/PHP-and-MySQL/C4/User-Password-Change-Part-2/English&quot; title=&quot;PHP-and-MySQL/C4/User-Password-Change-Part-2/English&quot;&gt;PHP-and-MySQL/C4/User-Password-Change-Part-2/English&lt;/a&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 15:57, 1 December 2012&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pravin1389</name></author>	</entry>

	<entry>
		<id>https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Password-Change-Part-2/English&amp;diff=598&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Time !Narration |- |0:00 |Welcome to the 2nd part of our “Change Password” tutorial. In the last  one, we learnt how to check if our forms were submitted.  |- |0…'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Password-Change-Part-2/English&amp;diff=598&amp;oldid=prev"/>
				<updated>2012-11-29T07:06:13Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Time !Narration |- |0:00 |Welcome to the 2nd part of our “Change Password” tutorial. In the last  one, we learnt how to check if our forms were submitted.  |- |0…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{| border=1&lt;br /&gt;
!Time&lt;br /&gt;
!Narration&lt;br /&gt;
|-&lt;br /&gt;
|0:00&lt;br /&gt;
|Welcome to the 2nd part of our “Change Password” tutorial. In the last  one, we learnt how to check if our forms were submitted. &lt;br /&gt;
|-&lt;br /&gt;
|0:09&lt;br /&gt;
| We’ve got our data values in here. &lt;br /&gt;
|-&lt;br /&gt;
|0:13&lt;br /&gt;
|Please remember that inside our database, our passwords are encrypted. &lt;br /&gt;
|-&lt;br /&gt;
|0:18&lt;br /&gt;
|So, as soon as these fields are coming in,  I will encrypt them into an md 5 hash.&lt;br /&gt;
|-&lt;br /&gt;
|0:27&lt;br /&gt;
|Make sure you put the brackets.&lt;br /&gt;
|-&lt;br /&gt;
|0:35&lt;br /&gt;
|What I have highlighted here is our parameter.&lt;br /&gt;
|-&lt;br /&gt;
|0:38&lt;br /&gt;
|So, here we will have our md5 encrypted passwords.&lt;br /&gt;
|-&lt;br /&gt;
|0:43&lt;br /&gt;
|We will need to check this field to see whether they exist or not.  &lt;br /&gt;
|-&lt;br /&gt;
|0:51&lt;br /&gt;
|At the moment when we submit our form, we see that nothing really happens.&lt;br /&gt;
|-&lt;br /&gt;
|0:57&lt;br /&gt;
|First I will say “check password against db” and then we have to connect to our database.&lt;br /&gt;
|-&lt;br /&gt;
|1:08&lt;br /&gt;
|We have already connected to the database in several of these pages- like the Login page.&lt;br /&gt;
|-&lt;br /&gt;
|1:15&lt;br /&gt;
|You can put this into a separate file, say, “include” and” include connect .php”  with your one time login script in, so that you don’t have to keep typing it.&lt;br /&gt;
|-&lt;br /&gt;
|1:29&lt;br /&gt;
|But for our tutorial's sake, I will keep typing it over and over again because this is a good way to learn. &lt;br /&gt;
|-&lt;br /&gt;
|1:35&lt;br /&gt;
|We type here - &amp;quot;connect = mysql_connect&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:40&lt;br /&gt;
|And we will be connecting to our local host database, with my username as root and my password as nothing, I am going to select my database. &lt;br /&gt;
|-&lt;br /&gt;
|1:50&lt;br /&gt;
|So that is “phplogin” which here.  Lets go there and you can see it here.&lt;br /&gt;
|-&lt;br /&gt;
|1:58&lt;br /&gt;
|Our table is &amp;quot;users&amp;quot;,  which we can use later on.  &lt;br /&gt;
|-&lt;br /&gt;
|2:01&lt;br /&gt;
|Next we will create a query to get the passwords.&lt;br /&gt;
|-&lt;br /&gt;
|2:05&lt;br /&gt;
|So I will type “ query get” which is equal to mysql.......... &amp;quot;mysql query&amp;quot; and here we will type &amp;quot;SELECT password&amp;quot; - We need to ascertain the password from the database &amp;quot;users&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:26&lt;br /&gt;
|You can see here.  This is the &amp;quot;users&amp;quot; table.&lt;br /&gt;
|-&lt;br /&gt;
|2:31&lt;br /&gt;
|Then we type “Where username is equal to user”. This is our session variable holding our user’s user name.  &lt;br /&gt;
|-&lt;br /&gt;
|2:39&lt;br /&gt;
|So, what we are doing is we are selecting our password hash from this table where the username is equal to the session name, and that is equal to “Alex”.&lt;br /&gt;
|-&lt;br /&gt;
|2:49&lt;br /&gt;
|So, that should be a successful query.  And you can type at the end “ or die &amp;quot;Query didn’t work”&amp;quot; - some error message.&lt;br /&gt;
|-&lt;br /&gt;
|2:59&lt;br /&gt;
|You can be a bit imaginative with these error messages and type what you like.&lt;br /&gt;
|-&lt;br /&gt;
|3:08&lt;br /&gt;
|Same here.  You can say “or die”.  You can add your own error message in here but to save time, I am not going to right now.&lt;br /&gt;
|-&lt;br /&gt;
|3:17&lt;br /&gt;
|Now, we will use this slightly differently, before we use the &amp;quot;while&amp;quot; function to loop through every record in the data base.&lt;br /&gt;
|-&lt;br /&gt;
|3:25&lt;br /&gt;
|I was informed about this method through a comment someone posted.  I will say &amp;quot;row = mysql_fetch_associative&amp;quot;.  And that‘s &amp;quot;query get&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|3:41&lt;br /&gt;
|We will set “old password db” which is a new variable name .  Don’t mistake this with the old password that has been submitted.&lt;br /&gt;
|-&lt;br /&gt;
|3:50&lt;br /&gt;
|Our old password inside the database will be equal to our row.&lt;br /&gt;
|-&lt;br /&gt;
|3:55&lt;br /&gt;
|Remember this creates an array.  &lt;br /&gt;
|-&lt;br /&gt;
|3:58&lt;br /&gt;
|So this value is” password”, because inside our database, this is “password” here. You need to use the labels.&lt;br /&gt;
|-&lt;br /&gt;
|4:06&lt;br /&gt;
|So from here on we can check our passwords.&lt;br /&gt;
|-&lt;br /&gt;
|4:08&lt;br /&gt;
|Checking our old passwords and our new passwords is just a simple “IF” statement. &lt;br /&gt;
|-&lt;br /&gt;
|4:16&lt;br /&gt;
|Lets type - if the old password is equal to the old password inside the database.&lt;br /&gt;
|-&lt;br /&gt;
|4:25&lt;br /&gt;
|These are both md5 hashes because we converted them into an md5 hash earlier.  &lt;br /&gt;
|-&lt;br /&gt;
|4:30&lt;br /&gt;
|So, if they are equal then we’ll run a block of code, otherwise we’ll kill the page and say ” Old password doesn’t match!”.&lt;br /&gt;
|-&lt;br /&gt;
|4:44&lt;br /&gt;
|So here, assuming we’ve got through the first stage of our validation,- we checked the old password with to old password in the database - now we need to  our two new passwords.&lt;br /&gt;
|-&lt;br /&gt;
|4:57&lt;br /&gt;
|Now this is just as simple as typing “if new password is equal to repeat new password”, then we can write a block of code, otherwise we can just kill the page and say “ New passwords don’t match!”.&lt;br /&gt;
|-&lt;br /&gt;
|5:20&lt;br /&gt;
|So here this is “success” and then we’ll say “change password in database”.&lt;br /&gt;
|-&lt;br /&gt;
|5:31&lt;br /&gt;
|So now what I’ll do is echo out “success” and I’ll go back to my page.&lt;br /&gt;
|-&lt;br /&gt;
|5:38&lt;br /&gt;
|I’ll type my password wrong on purpose. So I’ll just type this. &lt;br /&gt;
|-&lt;br /&gt;
|5:41&lt;br /&gt;
|My new password I’ll type as &amp;quot;abc&amp;quot; and then clicking on “change password” we get the message &amp;quot;Old password doesn’t match!&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|5:49&lt;br /&gt;
|If I type &amp;quot;abc&amp;quot; as my old password, which it is, and &amp;quot;123&amp;quot; as my new password and random letters in the next, we should get.....Oh &amp;quot;Old password doesn’t match!&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|6:00&lt;br /&gt;
|Lets go back and check the code.   Old password......... row - password............ query get........ &lt;br /&gt;
|-&lt;br /&gt;
|6:13&lt;br /&gt;
|What we can do here to debug is just say “echo old password db” with a break on the end, and just say echo old password with another break.&lt;br /&gt;
|-&lt;br /&gt;
|6:31&lt;br /&gt;
|What we can do now is, run the script again, so old password equals &amp;quot;abc&amp;quot;, new password equals &amp;quot;123&amp;quot; and then random letters.&lt;br /&gt;
|-&lt;br /&gt;
|6:44&lt;br /&gt;
|okay so let’s compare these. They both look the same to me, so we can see that we’ve got a problem here.&lt;br /&gt;
|-&lt;br /&gt;
|6:50&lt;br /&gt;
|Again lets check the code.  Checking for the spellings.&lt;br /&gt;
|-&lt;br /&gt;
|7:15&lt;br /&gt;
|Ok I just found out the problem. If I go back to my database here, we see that I had added in this value myself and I had created this space at the end of this - you can see it highlighted in blue - I’ll just get rid of that quickly and I’ll come back to my page.&lt;br /&gt;
|-&lt;br /&gt;
|7:33&lt;br /&gt;
|I’ll login again as usual and quickly change my password, I’ll put my old password in correctly and random text for my two new passwords. &lt;br /&gt;
|-&lt;br /&gt;
|7:45&lt;br /&gt;
|You can see that my two new passwords don’t match.&lt;br /&gt;
|-&lt;br /&gt;
|7:49&lt;br /&gt;
|We've echoed this out already, so now we can delete this.&lt;br /&gt;
|-&lt;br /&gt;
|7:53&lt;br /&gt;
|So assuming my passwords do match, let me echo this success message. &lt;br /&gt;
|-&lt;br /&gt;
|7:58&lt;br /&gt;
|So let’s just delete these. I put them for debugging.&lt;br /&gt;
|-&lt;br /&gt;
|8:02&lt;br /&gt;
|I’ll just type in my old password, my new passwords 123 and 123, click change password, and we’ve got success. &lt;br /&gt;
|-&lt;br /&gt;
|8:10 &lt;br /&gt;
|So I apologise for that last slip-up there.&lt;br /&gt;
|-&lt;br /&gt;
|8:18&lt;br /&gt;
|So in the 3rd part of this tutorial, we will continue with updating the user's password and just making sure everything’s working properly.  &lt;br /&gt;
|-&lt;br /&gt;
|8:29&lt;br /&gt;
|Thanks for watching. This is Joshwa Mathew dubbing for the Spoken Tutorial Project.&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>