Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is isset($_POST['submit1']) equal to FALSE?
    text
    copied!<p>This is a follow-up of another question that I posted a few hours ago (<a href="https://stackoverflow.com/questions/18325764/php-post-method-apparently-not-working">PHP post method apparently not working</a>). The code still does not do what it should, but the code and also the question itself have changed so much that I prefer to post a new question (also considering that questions seem to be read mainly immediately after they have been posted). I’ll try to close the earlier question (still somewhat new here).</p> <p>On to the question then: why is, in the code given below, isset($_POST['submit1']) equal to FALSE when tested? In other words, why is $_POST['submit1'] equal to NULL? I believe that’s all I need to know.</p> <p>Here is the code, which consists of two files. The file ‘form.php’ (copied almost literally from the jQuery-site: <a href="http://www.visualjquery.net/category/Ajax/jQuery.post" rel="nofollow noreferrer">http://www.visualjquery.net/category/Ajax/jQuery.post</a> , see last example) contains the following code:</p> <pre><code>&lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;title&gt;jQuery.post demo&lt;/title&gt; &lt;script src="http://code.jquery.com/jquery-1.9.1.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="formprocessing.php" name="formpje" id="searchForm"&gt; &lt;input type="text" name="s" placeholder="Search..." /&gt; &lt;input type="submit" value="Search" name="submit1" /&gt; &lt;/form&gt; &lt;!-- the result of the search will be rendered inside this div --&gt; &lt;div id="result"&gt;&lt;/div&gt; &lt;script&gt; /* attach a submit handler to the form */ $("#searchForm").submit(function(event) { /* stop form from submitting normally */ event.preventDefault(); /* get some values from elements on the page: */ var $form = $( this ), term = $form.find( 'input[name="s"]' ).val(), url = $form.attr( 'action' ); /* Send the data using post */ var posting = $.post(url,{s: term},'json'); /* Put the results in a div */ posting.done(function( data ) { var content1 = $( data ).find( '#content' ); contentstring = JSON.stringify(content1); $( "#result" ).empty().append( contentstring ); }); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>And the file ‘formprocessing.php’ contains the following (this includes the isset-test):</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;?php if(isset($_POST['submit1'])) { echo ( json_encode(array("content" =&gt; $invoer)) ); } ?&gt; </code></pre> <p>Thanks!</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