
December 23rd, 2012, 12:26 PM
|
|
Contributing User
|
|
Join Date: Dec 2012
Posts: 42
Time spent in forums: 5 h 48 m 13 sec
Reputation Power: 1
|
|
|
Php form
1. file.php
<html>
<body>
<?php
session_start();
$_SESSION['num1'] = mt_rand(1,5);
$q1 = $_SESSION['num1'] ;
echo "$q1";
$_SESSION['num2'] = mt_rand(6,20);
$q2 = $_SESSION['num2'] ;
?>
<form name="lab5" method="post" action="f2.php">
<table border=1 cellspacing=0 cellpading=0>
<tr> <td> Q1 </td> <td> <?php echo $q1 ?> * <?php echo $q2 ?> </td> <td> <input type = 'text' size = '2' name = one > </td> </tr>
<tr><td colspan=6 align='right'><input type='submit' value='Score' name='btn_score'></td></tr>
</table>
</form>
</body>
</html>
2. f2.php
<?php
session_start();
echo $_SESSION['num1'];
echo $_SESSION['num2'];
$UserV = $_POST['one'];
echo "userValue is $UserV";
$OneResult = $_SESSION['num1'] * $_SESSION['num2'] ;
echo "result is $OneResult " ;
?>
When i run file1.php, I get blank value for $userV after i enter a value.
but i get correct value for $oneresult.
How can i get the $UserV in f2 page?
Please help.
|