Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting Value of Form Input Php
    text
    copied!<p>I have this HTML:</p> <pre><code>&lt;?php if(!empty($_GET['pID'])) $the_pID = mysql_real_escape_string($_GET['pID']); #echo $the_pID; ?&gt; &lt;form action="inc/q/prof.php?pID=&lt;?php echo $the_pID; ?&gt;" method="post"&gt; &lt;select id="courseInfoDD" name="courseInfoDD" tabindex="1"&gt; &lt;?php while($row3 = $sth3-&gt;fetch(PDO::FETCH_ASSOC)) { echo "&lt;option&gt;".$row3['prefix']." ".$row3['code']."&lt;/option&gt;"; } echo "&lt;/select&gt;"; ?&gt; &lt;input type="text" id="addComment" name="addComment" tabindex="3" value="Enter comment" /&gt; &lt;input type="hidden" name="pID" value="&lt;?php echo $the_pID; ?&gt;"&gt; &lt;input type="submit" name="submit" id="submit" /&gt; &lt;/form&gt; </code></pre> <p>THIS PHP:</p> <pre><code>&lt;?php $connect = mysql_connect("###", $username, $password) or die ("Error , check your server connection."); mysql_select_db("###"); //Get data in local variable if(!empty($_POST['addComment'])) $INFOO = mysql_real_escape_string($_POST['addComment']); if(!empty($_POST['pID'])) $PIDD = mysql_real_escape_string($_POST['pID']); if(!empty($_POST['courseInfoDD'])) $COURSEE = mysql_real_escape_string($_POST['courseInfoDD']); #print_r($_POST); echo $the_pID; // check for null values if (isset($_POST['submit'])) { $query="INSERT INTO Comment (info, pID, cID) VALUES ('$INFOO','$PIDD','$COURSEE')"; mysql_query($query) or die(mysql_error()); echo "Your message has been received"; } #else if(!isset($_POST['submit'])){echo "No blank entries";} #else{echo "Error!";} ?&gt; </code></pre> <p>I'm trying to get the value of the code: </p> <pre><code>&lt;select id="courseInfoDD" name="courseInfoDD" tabindex="1"&gt; &lt;?php while($row3 = $sth3-&gt;fetch(PDO::FETCH_ASSOC)) { echo "&lt;option&gt;".$row3['prefix']." ".$row3['code']."&lt;/option&gt;"; } echo "&lt;/select&gt;"; ?&gt; </code></pre> <p>And insert it into <code>php variable $COURSEE</code> which is then being inserted above.</p> <h2>Issue</h2> <p>A Zero inserted for this value?? Which means it has nothing to insert, correct?? Anyone see anything</p>
 

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