Passing html attribute value to the next script in php

Posted by NewBiL on Stack Overflow See other posts from Stack Overflow or by NewBiL
Published on 2012-12-19T05:02:24Z Indexed on 2012/12/19 5:02 UTC
Read the original article Hit count: 141

Filed under:
|
|

I have three php scripts. main.php questions.php and values.php

Here's the code main.php

<html>
<head>
<title></title>
</head>

<body>
<h1>Be Prepare for the battle</h1>
<?php
$strTitle = "Begin";
$strLink = "<a href = 'question.php?ques_id=1'>" . $strTitle ."</a>";     
echo $strLink;
?>
</body>
</html>

questions.php

<?php       require_once('../connect.php');                             $quesSQL = mysql_query("SELECT * FROM  `questions` WHERE  `ques_id`=". $_GET["ques_id"]);

if(!mysql_num_rows($quesSQL)>=1)
{
die('Complete.');
}
$next = $_GET["ques_id"];                                   while($row = mysql_fetch_array($quesSQL)) {
$id = $row['ques_id'];
$strTitle = $row['ques_title'];
echo "<li>". $strTitle ."</li><br/>";           
}   

$optSQL = mysql_query("SELECT `options`,`values` FROM questions_options WHERE ".$id."= ques_id");
echo "<form action=\"values.php\" method=\"POST\">";
while($row = mysql_fetch_array($optSQL) ) {
$strOptions = $row['options'];  
$strValues = $row['values'];                            
echo "<input type =\"radio\" name =\"valueIn\" value=".$strValues." />". $strOptions ."<br/>";
}   
echo "</form>";
$strTitle = "<input type =\"submit\" value=\"Next\">";
$next = $next+1;
$strLink = "<a href = 'values.php?ques_id=".$next."'>" . $strTitle ."</a>";
echo $strLink;

mysql_close();                  
?>

and values.php

<?php
require_once('../connect.php'); 
$input = $_POST['valueIn'];
$ansSQL = mysql_query("SELECT `answer` FROM questions WHERE 1-".$_GET["ques_id"]."= ques_id");          

$marks = 0;         
if($input == $ansSQL)
{
$marks = $marks+1;
}
else
{
$marks = $marks+0;
}               
echo $marks;                            
?>

Now problem is i have to pass one value from second script(questions.php) to third script(values.php). And it is from the <form> section in radio button's name value "valueIn". But I can't do that. Because I'm sending another value ques_id with $strLink variable at the end of the second script. So how can i do that?

© Stack Overflow or respective owner

Related posts about php

Related posts about html5