Note that there are some explanatory texts on larger screens.

plurals
  1. POvalue $_POST from others page can't pass throught isset form
    primarykey
    data
    text
    <p>I have a problem on pass value <code>$result</code> from different page into another page.</p> <p>when I <code>POST</code> the value <code>$result</code> into this page. It works fine and I echo it out.</p> <p>but if i try to pass this <code>$result</code> into <code>isset()</code> form and post it back to self.<br> The value will become Undefined index.</p> <p>PAGE1</p> <pre><code>&lt;?PHP $connect=mysql_connect('localhost', 'root', ''); $db=mysql_select_db('survey', $connect); $SQL="SELECT * FROM question"; $data=mysql_query($SQL); $num=mysql_num_rows($data); $start=0; ?&gt; &lt;style type="text/css"&gt; #survey{ width:100%; height:50px; background:#e6e6e6; border-bottom:solid 1px white; } #survey form{ position:relative; left:320px; top:15px; float:left; } #survey form a{ text-decoration:none; color:black; } .submit{ background-color: transparent; border: none; cursor: pointer; } &lt;/style&gt; &lt;html&gt; &lt;div id="container"&gt; &lt;?PHP if($num&lt;3){ echo " &lt;div id='create'&gt;&lt;a href='question.php'&gt;+ Create a Survey&lt;/a&gt;&lt;/div&gt; "; } ?&gt; &lt;?PHP while($start&lt;$num){ $result=mysql_result($data, $start, 'ID'); $list_num=$start+1; $ID=$result['ID']; $list=" &lt;div id='survey'&gt; &lt;span style='font-size:24px; color:gray; position:relative; float:left; left:10px; top:13px;'&gt; SURVEY 0$list_num &lt;/span&gt; &lt;form action='survey.php' method='POST'&gt; &lt;input class='submit' type='submit' name='submit1' value='View' /&gt; &lt;input type='hidden' name='result' value='$ID'/&gt; &lt;/form&gt; &lt;form action='update.php' method='POST'&gt; &lt;input class='submit' type='submit' name='submit2' value='Edit' /&gt; &lt;input type='hidden' name='result' value='$ID'/&gt; &lt;/form&gt; &lt;form action='delete.php' method='POST'&gt; &lt;input class='submit' type='submit' name='submit3' value='&amp;#10005 Delete' /&gt; &lt;input type='hidden' name='result' value='$ID'/&gt; &lt;/form&gt; &lt;/div&gt; "; echo $list; $start++; } ?&gt; &lt;/div&gt; &lt;/html&gt; </code></pre> <p>PAGE2</p> <pre><code> &lt;?PHP $result=$_POST['result']; $error=""; if(isset($_POST['submit'])){ $question=$_POST['question']; $answer_a=$_POST['a']; $answer_b=$_POST['b']; $answer_c=$_POST['c']; if($question &amp;&amp; $answer_a &amp;&amp; $answer_b &amp;&amp; $answer_c){ $connect=mysql_connect("localhost", "root", ""); $db=mysql_select_db("survey", $connect) or die(""); $SQL="UPDATE question SET question='$question', answer_a='$answer_a', answer_b='$answer_b', answer_c='$answer_c' WHERE ID='$result'"; mysql_query($SQL); $SQL="UPDATE answer SET question='$question', answer_a='0', answer_b='0', answer_c='0' WHERE ID='$result' "; mysql_query($SQL); header("location:create.php"); } else{$error="&lt;div style='color:white; background:gray; width:200px; height:20px; text-align:center; line-height:20px;'&gt;" . "Please fill all the field." . "&lt;/div&gt;";} } ?&gt; &lt;style&gt; body{ font-family:Arial, Helvetica, sans-serif; font-size:14px; } &lt;/style&gt; &lt;html&gt; &lt;form action="update.php" method="POST"&gt; Question&lt;br /&gt;&lt;input type="text" name="question" placeholder=" Enter your question here" maxlength="50" /&gt;&lt;br/&gt;&lt;br/&gt;Answer&lt;br/&gt; a&lt;input type="text" name="a" placeholder=" Answer a" maxlength="50"/&gt; b&lt;input type="text" name="b" placeholder=" Answer b" maxlength="50"/&gt; c&lt;input type="text" name="c" placeholder=" Answer c" maxlength="50"/&gt; &lt;input type="submit" name="submit" value="SAVE"/&gt; &lt;/form&gt; &lt;?PHP echo $error; ?&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload