Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't set variable from $_POST
    primarykey
    data
    text
    <p>I can't set a variable from a post array. </p> <p>I have a simple form with a hidden field in it: <code>&lt;input name="sid" type="hidden" id="sid" value="&lt;?=$sid?&gt;"&gt;</code></p> <p>This hidden field gets sent off to a second file (exec.php) where I have the following code:</p> <pre><code>$sid = $_POST['sid']; </code></pre> <p>For some reason, when trying to set $sid, it gets a NULL value. For haha's, I ran the following:</p> <pre><code>foreach($_POST as $var =&gt; $value) { echo $var . ' : ' . $value . "&lt;br&gt;"; } </code></pre> <p>This provided a correct value of 1938 for sid. I've looked at this for 3 hours and can't find what is happening. I expect something extremely stupid...any thoughts? </p> <hr> <p>Here is the form on enter.php</p> <pre><code> &lt;form name="form1" method="post" action="exec.php"&gt; &lt;input name="sid" type="hidden" id="sid" value="&lt;? echo($sid); ?&gt;"&gt; &lt;input name="ticket_totals" type="hidden" id="ticket_totals" value="&lt;?=$ticket_totals?&gt;"&gt; &lt;input name="emp" type="hidden" id="emp" value="&lt;?=$emp?&gt;"&gt; &lt;input name="submit" type="submit" id="submit" value="Submit"&gt; &lt;input type="submit" name="submit" id="submit" value="Close"&gt; &lt;/form&gt; </code></pre> <p>Here is the POST output on exec.php: type : Other ticket_totals : 0 emp : 105 sid : 1939 submit : Submit</p> <hr> <p>Okay - this was poor syntax on my part but now I'm curious as to why.</p> <p>I left out quotation marks - the solution is as simple as this: $sid = $_POST["sid"]</p> <p>Now it works like a champ.</p> <p>Any takers on why? I'd guess there is a setting in the php.ini that requires the quotes. Strangely enough, I have other variables called from the POST array that i'm not using quotes for and they're working fine...</p>
    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.
    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