<?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-Login-Part-1%2FEnglish</id>
		<title>PHP-and-MySQL/C4/User-Login-Part-1/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-Login-Part-1%2FEnglish"/>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Login-Part-1/English&amp;action=history"/>
		<updated>2026-04-06T03:32:13Z</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-Login-Part-1/English&amp;diff=895&amp;oldid=prev</id>
		<title>Pravin1389: moved PHP-and-MySQL/C4/User-Login-(Part 1)/English to PHP-and-MySQL/C4/User-Login-Part-1/English</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Login-Part-1/English&amp;diff=895&amp;oldid=prev"/>
				<updated>2012-12-01T15:47:50Z</updated>
		
		<summary type="html">&lt;p&gt;moved &lt;a href=&quot;/index.php/PHP-and-MySQL/C4/User-Login-(Part_1)/English&quot; class=&quot;mw-redirect&quot; title=&quot;PHP-and-MySQL/C4/User-Login-(Part 1)/English&quot;&gt;PHP-and-MySQL/C4/User-Login-(Part 1)/English&lt;/a&gt; to &lt;a href=&quot;/index.php/PHP-and-MySQL/C4/User-Login-Part-1/English&quot; title=&quot;PHP-and-MySQL/C4/User-Login-Part-1/English&quot;&gt;PHP-and-MySQL/C4/User-Login-Part-1/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:47, 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-Login-Part-1/English&amp;diff=591&amp;oldid=prev</id>
		<title>Chandrika: Created page with '{| border=1 !Time !Narration |- |0:00 |Welcome to the tutorial on user login and sessions.  |- |0:03 |This tutorial will give a few aspects of php that will focus on how an html …'</title>
		<link rel="alternate" type="text/html" href="https://script.spoken-tutorial.org/index.php?title=PHP-and-MySQL/C4/User-Login-Part-1/English&amp;diff=591&amp;oldid=prev"/>
				<updated>2012-11-29T07:03:26Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;{| border=1 !Time !Narration |- |0:00 |Welcome to the tutorial on user login and sessions.  |- |0:03 |This tutorial will give a few aspects of php that will focus on how an html …&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 tutorial on user login and sessions. &lt;br /&gt;
|-&lt;br /&gt;
|0:03&lt;br /&gt;
|This tutorial will give a few aspects of php that will focus on how an html form can be submitted and how to check for user name and password. &lt;br /&gt;
|-&lt;br /&gt;
|0:14&lt;br /&gt;
|The entered values will be checked against a database.&lt;br /&gt;
|-&lt;br /&gt;
|0:16&lt;br /&gt;
|I'll show you how to set-up a database with your user name and password, how to connect to a database and also to process a logout function. &lt;br /&gt;
|-&lt;br /&gt;
|0:25&lt;br /&gt;
|Since we're using sessions, the user will remain logged-in until they press the logout button.&lt;br /&gt;
|-&lt;br /&gt;
|0:32&lt;br /&gt;
|To start with I'll create an html form. &lt;br /&gt;
|-&lt;br /&gt;
|0:35&lt;br /&gt;
|I'll take you through some of the mySQL features that we will set up.&lt;br /&gt;
|-&lt;br /&gt;
|0:42&lt;br /&gt;
|In our html form, we have the action going to a page called &amp;quot;login dot php&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|0:47&lt;br /&gt;
|We'll keep separate pages to keep it simple. &lt;br /&gt;
|-&lt;br /&gt;
|0:49&lt;br /&gt;
|Our method is going to be POST.&lt;br /&gt;
|-&lt;br /&gt;
|0:50&lt;br /&gt;
|Lets end our form here. &lt;br /&gt;
|-&lt;br /&gt;
|0:54&lt;br /&gt;
|I'll start creating our input type which will be &amp;quot;text&amp;quot; and the name will be &amp;quot;username&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|1:06&lt;br /&gt;
|A line break here. &lt;br /&gt;
|-&lt;br /&gt;
|1:09&lt;br /&gt;
|Copy-paste this line and change &amp;quot;text&amp;quot; to &amp;quot;password&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:15&lt;br /&gt;
| And its called &amp;quot;password&amp;quot;.  Depending on which operating system we are using, this will appear as stars or circles.&lt;br /&gt;
|-&lt;br /&gt;
|1:24&lt;br /&gt;
|And finally we'll create a &amp;quot;submit&amp;quot; button and its value will be &amp;quot;Log in&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|1:31&lt;br /&gt;
| Let's try this. Refresh and we have a page here. &lt;br /&gt;
|-&lt;br /&gt;
|1:36&lt;br /&gt;
|&amp;quot;index dot php&amp;quot; with a user name and password. &lt;br /&gt;
|-&lt;br /&gt;
|1:39&lt;br /&gt;
|I'll log in and it goes to a page that doesn't exist.&lt;br /&gt;
|-&lt;br /&gt;
|1:43&lt;br /&gt;
|Now let's make it a bit more user friendly and type out labels here.&lt;br /&gt;
|-&lt;br /&gt;
|1:54&lt;br /&gt;
|Refresh and there we are.&lt;br /&gt;
|-&lt;br /&gt;
|1:59&lt;br /&gt;
|Now let us create our &amp;quot;login dot php&amp;quot; file. &lt;br /&gt;
|-&lt;br /&gt;
|2:01&lt;br /&gt;
|First I will open &amp;quot;php my admin&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:04&lt;br /&gt;
|If you are using &amp;quot;xampp&amp;quot; then it will be installed by default using the local host for &amp;quot;php my admin&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|2:11&lt;br /&gt;
|If it isn't installed yet, I would suggest you google it and install a copy on the local host directory and start using it.  &lt;br /&gt;
|-&lt;br /&gt;
|2:21&lt;br /&gt;
|Now, we'll create a new database. &lt;br /&gt;
|-&lt;br /&gt;
|2:25&lt;br /&gt;
|So here, create new database called &amp;quot;php login&amp;quot; and click create.&lt;br /&gt;
|-&lt;br /&gt;
|2:40&lt;br /&gt;
|We can see it appears here and we can now create tables.&lt;br /&gt;
|-&lt;br /&gt;
|2:46&lt;br /&gt;
|In case you're not familiar with sql, let me brief you. &lt;br /&gt;
|-&lt;br /&gt;
|2:50&lt;br /&gt;
|A basic structure is a database which stores tables and tables store rows and rows store values. &lt;br /&gt;
|-&lt;br /&gt;
|3:00&lt;br /&gt;
|Lets name it &amp;quot;users&amp;quot; and click on OK. &lt;br /&gt;
|-&lt;br /&gt;
|3:06&lt;br /&gt;
|An error - the number of fields! &lt;br /&gt;
|-&lt;br /&gt;
|3:10&lt;br /&gt;
|When I create a new database, I open up a notepad or a context editor and note down all the fields that I'll use. &lt;br /&gt;
|-&lt;br /&gt;
|3:20&lt;br /&gt;
|I'll use &amp;quot;id&amp;quot; for start, next &amp;quot;user name&amp;quot; and lastly &amp;quot;password&amp;quot;. That's all we want at the moment.&lt;br /&gt;
|-&lt;br /&gt;
|3:28&lt;br /&gt;
|We can also add the &amp;quot;first name&amp;quot;, &amp;quot;date of birth&amp;quot; etc. depending on your program. &lt;br /&gt;
|-&lt;br /&gt;
|3:36&lt;br /&gt;
|But for now we're using these 3 fields making it a total of 3 fields. &lt;br /&gt;
|-&lt;br /&gt;
|3:42&lt;br /&gt;
|Let's go back here. So, three fields and that will create that first. &lt;br /&gt;
|-&lt;br /&gt;
|3:49&lt;br /&gt;
|Now we proceed with typing in the the field names. &lt;br /&gt;
|-&lt;br /&gt;
|3:53&lt;br /&gt;
|We type &amp;quot;id&amp;quot; and we will make this an integer. &lt;br /&gt;
|-&lt;br /&gt;
|3:57&lt;br /&gt;
|This is the primary key and we want it to make auto increment.  &lt;br /&gt;
|-&lt;br /&gt;
|4:02&lt;br /&gt;
|Now, every-time a new record is created the id values will increment by one. &lt;br /&gt;
|-&lt;br /&gt;
|4:07&lt;br /&gt;
|So, for example, the first user who registers will have an id of one, the second user who registers will have an id of two and so on and so forth. &lt;br /&gt;
|-&lt;br /&gt;
|4:15&lt;br /&gt;
|Okay, next one will be the user name and last one is going to be the password. &lt;br /&gt;
|-&lt;br /&gt;
|4:23&lt;br /&gt;
|Next we'll set them as VARCHARs and I'll set this as 25 characters and the password as 25 characters, as well.&lt;br /&gt;
|-&lt;br /&gt;
|4:31&lt;br /&gt;
|There is nothing else that we need to set for these.&lt;br /&gt;
|-&lt;br /&gt;
|4:34&lt;br /&gt;
|Let us scroll down and lets click on SAVE. &lt;br /&gt;
|-&lt;br /&gt;
|4:40&lt;br /&gt;
|Okay so once I save here, we can come down and see this here. &lt;br /&gt;
|-&lt;br /&gt;
|4:44&lt;br /&gt;
|And you can insert values in them. &lt;br /&gt;
|-&lt;br /&gt;
|4:48&lt;br /&gt;
|We'll do it because we're testing. &lt;br /&gt;
|-&lt;br /&gt;
|4:50&lt;br /&gt;
|I have created some tutorials on how to make a user registration form. We can discuss this further there.&lt;br /&gt;
|-&lt;br /&gt;
|5:01&lt;br /&gt;
|The value of &amp;quot;id&amp;quot; will be auto-incremented, so we don't have to put anything. &lt;br /&gt;
|-&lt;br /&gt;
|5:05&lt;br /&gt;
|It'll go to 1 straight away. &lt;br /&gt;
|-&lt;br /&gt;
|5:07&lt;br /&gt;
|In user name, I'll say &amp;quot;Alex&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|5:10&lt;br /&gt;
|My password will be &amp;quot;abc&amp;quot;.  I would recommend you a better password, though. &lt;br /&gt;
|-&lt;br /&gt;
|5:16&lt;br /&gt;
|Okay so user name is &amp;quot;Alex&amp;quot; and password is &amp;quot;abc&amp;quot; - easy to remember. That's what has been stored. &lt;br /&gt;
|-&lt;br /&gt;
|5:26&lt;br /&gt;
|To browse, just click the browse tab. &lt;br /&gt;
|-&lt;br /&gt;
|5:28&lt;br /&gt;
|Let's scroll down. We have user name and password as &amp;quot;Alex&amp;quot; and &amp;quot;abc&amp;quot; and the id has already been set to 1.&lt;br /&gt;
|-&lt;br /&gt;
|5:37&lt;br /&gt;
|Now, we'll create the &amp;quot;login dot php&amp;quot; page. &lt;br /&gt;
|-&lt;br /&gt;
|5:46&lt;br /&gt;
|Lets save this quickly - &amp;quot;Login dot php&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|5:51&lt;br /&gt;
|Let us see how to create our php tags.  &lt;br /&gt;
|-&lt;br /&gt;
|5:55&lt;br /&gt;
|I'll take into account some POST variables now.&lt;br /&gt;
|-&lt;br /&gt;
|5:59&lt;br /&gt;
|In &amp;quot;index dot php&amp;quot;, we used the method as POST. &lt;br /&gt;
|-&lt;br /&gt;
|6:01&lt;br /&gt;
|We'll set user name as dollar sign underscore POST and rename the variable which is &amp;quot;username&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|6:11&lt;br /&gt;
|It is found here and.... password will equal a POST value and that will be &amp;quot;password&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|6:25&lt;br /&gt;
|First of all, we will check whether both the user name and the password were entered. &lt;br /&gt;
|-&lt;br /&gt;
|6:30&lt;br /&gt;
|We won't start validating the form. Its unnecessary to do so since we know the user has entered both these fields.&lt;br /&gt;
|-&lt;br /&gt;
|6:38&lt;br /&gt;
|Now, I will type my &amp;quot;if&amp;quot; statement. &lt;br /&gt;
|-&lt;br /&gt;
|6:40&lt;br /&gt;
|This will be a big block because all the code that I require after I check this will go in here.&lt;br /&gt;
|-&lt;br /&gt;
|6:45&lt;br /&gt;
|So here I'll say if &amp;quot;username&amp;quot; which means if &amp;quot;username&amp;quot; has a value, it will return TRUE and I'll say &amp;quot;password&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|6:56&lt;br /&gt;
|So this requires the &amp;quot;username&amp;quot; and &amp;quot;password&amp;quot; for this to be TRUE and to execute this block of code here. &lt;br /&gt;
|-&lt;br /&gt;
|7:04&lt;br /&gt;
|What should we write here?  We need to connect to our database. &lt;br /&gt;
|-&lt;br /&gt;
|7:08&lt;br /&gt;
|To do this we create a variable called &amp;quot;connect&amp;quot; equal to &amp;quot;mysql_connect&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|7:20&lt;br /&gt;
|And inside this the first parameter will be a &amp;quot;host&amp;quot; which is &amp;quot;localhost&amp;quot; for me. &lt;br /&gt;
|-&lt;br /&gt;
|7:28&lt;br /&gt;
|The second one will be &amp;quot;username&amp;quot; and I'll use &amp;quot;root&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|7:31&lt;br /&gt;
|The third one is the &amp;quot;password&amp;quot; which I believe I don't have.  We'll check on that.&lt;br /&gt;
|-&lt;br /&gt;
|7:37&lt;br /&gt;
|After this we can say &amp;quot;or die&amp;quot; and give an error message. &lt;br /&gt;
|-&lt;br /&gt;
|7:39&lt;br /&gt;
|So, for example, we can say &amp;quot;Couldn't connect&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|7:44&lt;br /&gt;
|I am not sure about my password.  I think its something else.  &lt;br /&gt;
|-&lt;br /&gt;
|7:48&lt;br /&gt;
|We'll try something then it will say &amp;quot;Couldn't connect&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
|7:51&lt;br /&gt;
|Now we need to select our table, sorry our database. &lt;br /&gt;
|-&lt;br /&gt;
|7:58&lt;br /&gt;
|We'll say &amp;quot;mysql select db&amp;quot; which is another built-in function when you have the php module installed.&lt;br /&gt;
|-&lt;br /&gt;
|8:06&lt;br /&gt;
|It also comes with XAMPP.&lt;br /&gt;
|-&lt;br /&gt;
|8:11&lt;br /&gt;
|Here I'll put a double quote and say &amp;quot;phplogin&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|8:19&lt;br /&gt;
|So assuming that everything is okay, I can add my error message here &amp;quot;Couldn't find db&amp;quot;. Okay?. &lt;br /&gt;
|-&lt;br /&gt;
|8:30&lt;br /&gt;
|Refresh page.  Click login.  Nothing happened. &lt;br /&gt;
|-&lt;br /&gt;
|8:37&lt;br /&gt;
|Let's edit our &amp;quot;if&amp;quot; statement and say &amp;quot;else&amp;quot; echo or instead the best function is &amp;quot;die&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|8:47&lt;br /&gt;
|Here it will just stop executing anything after this point, after this function is called. &lt;br /&gt;
|-&lt;br /&gt;
|8:54&lt;br /&gt;
|And it'll also pass a message of your choice. &lt;br /&gt;
|-&lt;br /&gt;
|8:58&lt;br /&gt;
|So here I'll say &amp;quot;Please enter a user name and a password&amp;quot;. &lt;br /&gt;
|-&lt;br /&gt;
|9:08&lt;br /&gt;
|Refresh this. Resend the data and we get this error message.&lt;br /&gt;
|-&lt;br /&gt;
|9:13&lt;br /&gt;
|Next I'll type &amp;quot;Alex&amp;quot; and &amp;quot;123&amp;quot;, sorry &amp;quot;abc&amp;quot; and click log in. &lt;br /&gt;
|-&lt;br /&gt;
|9:18&lt;br /&gt;
|No error message, which means we are connected to the database. &lt;br /&gt;
|-&lt;br /&gt;
|9:25&lt;br /&gt;
|That's the end of this part.  In the next one I will show how to connect to our database and check for the user name and password. &lt;br /&gt;
|-&lt;br /&gt;
|9:34&lt;br /&gt;
|Thanks for joining us. This is Royston dubbing for the Spoken Tutorial Project. Bye.&lt;/div&gt;</summary>
		<author><name>Chandrika</name></author>	</entry>

	</feed>