Reading Data in a form: using password control, lesson -7-…

October 5
I

n this lesson, I will talk about reading data in a form using password control. One of  PHP usage is to check passwords on the server to give the user the access to the resources or not. Therefore, learning to use password control is very essential in web pages. So Let’s begin…

 

Step *1: as we used to do, open xammp control panal, open your browser and open the editor. In htdocs folder create another folder and name it (password). Inside this folder you will save the two files we will create in this lesson. password.html and phppassword.php.

 

Step *2: using the editor, create an HTML file, name it password.html, type this code in it and save.


<html>

<head>

<title>enterind data with password control</title>

</head>

<body>

<h1>

entering data with password control

</h1>

<form method="post" action="phppassword.php">

enter your password:

<input name="password" type="password">

<br/>

<br/>

<input type="submit" value="send">

</body>

</html>

We will use “input” attribute, because we are intering data in a form. But instead of typing “text” in “type” attribute, we will type “password”.

 

Step *3: For reading data in a form using password control, Create a PHP file and name it phppassword.php. Type this code in it and save.


<html>

<head>

<title>reading data from password control</title>

</head>

<body>

<h1>

reading data from password control

</h1>

<?php

if($_REQUEST["password"] =="mypass") {

?>

<h2>

password accepted

</h2>

ok, you are in. <br/>

welcome...

<?php

}

else {

?>

<h2>

password denied.

</h2>

you did not enter the right password...please try again...<br/>

<?php

}

?>

</body>

</html>

One of the charm of PHP is the ability of storing passwords in the server. And this will help us in checking password verification, if it matches then the user will access to the resources if not he can’t.

 

In this case I used the password “mypass”, and I will check it with the password sent by $_request[“password”]. If it matches, a welcome message will appear to the user, if not an error message will notify him to retry again.

 

That’s all for this lesson. The next one I will talk about reading data in a form using hidden control, seeyas.

 


StumbleUpon.com Add us to your digg favorites Add us to your delicious favorites add us to your facebook favorites follow us on twitter Add us to your technorati favorites Add us to your wordpress favorites Add us to your reddit favorites Add us to livejournal favorites

Leave a Reply