Note that there are some explanatory texts on larger screens.

plurals
  1. POPOST variable not changing
    text
    copied!<p>I have a form with some jQuery UI sortables that have <code>data-</code>attributes that get serialized into a hidden textbox, so when I send the form, my PHP script can look at the value of <code>$_POST["contents"]</code>(which is a string like this <code>1-2-2-1</code>) and pass it to my MySQL UPDATE query. The problem is, the reported value of the textbox before sending the form (from the javascript), is different than the one in <code>$_POST</code>.</p> <p><strong>The form:</strong></p> <pre><code>&lt;form method="post" action="?update"&gt; &lt;input type="text" name="id" style="display:none" value="1" /&gt; &lt;input type="text" name="path" placeholder="Endereço Ex.: /pacotes/pureenergy" value="/some/path" /&gt; &lt;input type="text" name="title" placeholder="Título da página" value="&lt;?php echo $t;?&gt;" /&gt;&lt;br /&gt; &lt;!-- Some stuff hidden for briefness --&gt; &lt;input type="text" id="ci" name="contents" style="display:none" value="1-2-2-1" /&gt; &lt;input type="submit" value="Atualizar página" onclick="updateForm()"&gt; &lt;/form&gt; </code></pre> <p><strong>The Javascript:</strong></p> <pre><code>function updateForm() { var txt = $("#dropzone li:first-of-type").data("id"); $("#dropzone li:not(:first-of-type)").each(function() { txt = txt+"-"+$(this).data("id"); }); $("#ci").text(txt); alert(txt); } </code></pre> <p><strong>The PHP:</strong></p> <pre><code>$id = $_POST["id"]; $p = $_POST["path"]; $t = $_POST["title"]; $c = $_POST["contents"]; mysql_query("UPDATE aruna.pages SET path='$p', title='$t', contents='$c' WHERE id=$id") or die(mysql_error()); </code></pre> <p>The value reported by the javascript <code>alert()</code> is behaving as intended, but when I send the form, the value of the <code>$_POST["contents"]</code> is the same that was hardcoded in the HTML.</p> <p><strong>EDIT:</strong> PHP doesn't complain about <code>$_POST["contents"]</code> being unset, which it would if there was a typo.</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