Reading Data in a form: using hidden control, lesson -8-…

October 12
R

eading data in a form using hidden control is our lesson for today. Html hidden control and PHP script could work perfectly together. Because they let us store data in web pages but the user couldn’t usually see it (the user can see hidden data if he checks the web page’s source code). And then we can use them on the server. So, let’s begin…

 

Step *1: open xammp control panal, open your browser and open the editor. In htdocs folder create a new folder and name it (hiddencontrol). In this folder you will save the two files we will create in this lesson. hiddencontrol.html and phphiddencontrol.php.

 

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


<html>

<head>

<title>storing data with hidden control</title>

</head>

<body>

<h1>

storing data with hidden control

</h1>

what kind of users do you think you are?? <br/>

click the button to find out... <br/>

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

<input name="user_type" type="hidden" value="good">

<br/>

<br/>

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

</form>

</body>

</html>

In this example, I will set a hidden control named “user_type” to store what I think of the user, behind the scenes. And I will set it to “good”. As you can see it is a normal “input” attribute, with ” name” attribute to give it a name, “type” to specify the type of input element, and here we will type hidden and “value” to set a value to this hidden control.

 

Step *3: Create a PHP file and name it phphiddencontrol.php. Type this code in it and save.


<html>

<head>

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

</head>

<body>

<h1>

reading data from hidden control

</h1>

i think you are a....

<?php

echo $_REQUEST["user_type"];

?>

...user...

</body>

</html>

In PHP file we will just echo the data in REQUEST[“user_type”] to show the result. Hidden controls is a popular way to store information about the user, another way is using cookies.

 

Lesson -8- is finished, and next lesson I will talk about reading data in a form using image maps, 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