PHP SESSION AND FIELD VALIDATION
Posted: Sun Sep 19, 2010 6:21 pm
Hi
I am just stucked. Would be great if someone can help me.
I have created form. Has also created a session in php to view the data and reuse it for editting any data. While trying to edit all the default values which are inputed in the form are coming in all fields except the value for radio button(no value is checked)
I am giving a short coding for all 3 pages:
Page 1: (HTML- FORM)
PAGE 2 (Displaying Input Values)
Page 3 (editing field with prefilled fields) The problem is in this section:
When I am clicking Edit button on page2, page3 is appearing where name field is prefilled but no radio buttons are checked. I need help for the radio button to be checked according to the information given on first page.
Also, it will be a great help if someone can tell me how to validate the fields on page3 before processing to page4.
THank you ver very much.......
I am just stucked. Would be great if someone can help me.
I have created form. Has also created a session in php to view the data and reuse it for editting any data. While trying to edit all the default values which are inputed in the form are coming in all fields except the value for radio button(no value is checked)
I am giving a short coding for all 3 pages:
Page 1: (HTML- FORM)
Code: Select all
<html>
<body>
<form action="page2.php" method="post">
Name : <input type="text" name="name"/>
Discount: <input type="radio" name="discount" value="2"> TWO </br>
<input type="radio" name="discount" value="4"> THREE
<input type="submit" value="Submit"/>
</form>
</body>
</html>
Code: Select all
<html>
<?php session_start();?>
<body>
<form action="page3.php" method="post">
Name :<?php
$name=$_POST['name'];
$_SESSION['name']=$name;
echo $_SESSION['name']; ?>
Discount:<?php
$discount=$_POST['discount'];
$_SESSION['discount']=$discount;
echo $_SESSION['discount']; ?>
<input type="Submit" value="Edit">
</form>
</body>
</html>Code: Select all
<html>
<?php session_start();?>
<head>
<?php
$name=$_SESSION['name'];
$discount=$_SESSION['discount'];
echo
"<form action=\"page4.php\" method=\"POST\">
Name :<input type=\"text\" name=\"name\" value=\"$name\"/> </br>
<input type=\"radio\" name=\"discount\" value=\"2\"<?php if($discount=='2') echo 'checked=\"checked\"'; ?> TWO
<br/>
<input type=\"radio\" name=\"discount\" value=\"4\" <?php if($discount=='4') echo 'checked=\"checked\"'; ?> FOUR
<br/>
<input type=\"submit\" value=\"Confirmed\"/>";
?>
</body>
</html>Also, it will be a great help if someone can tell me how to validate the fields on page3 before processing to page4.
THank you ver very much.......