Note that there are some explanatory texts on larger screens.

plurals
  1. POForm / ajax / PHP issue
    primarykey
    data
    text
    <p>I am trying to make a small form that lets the user pick one element from 3 different radiobutton lists to set one element as the users active element (that will be stored to MySQL). Somehow along the way it does not work and I can not seem to figure out why, perhaps someone of you can see what I did wrong?</p> <p>HTML:</p> <pre><code>&lt;form name="activeForm1" method="post"&gt; &lt;fieldset data-role="controlgroup"&gt; &lt;div class="ui-radio"&gt; &lt;input type="radio" name="active" value="1" id="1"&gt; &lt;label for="1"&gt;&lt;/label&gt;&lt;/input&gt; &lt;/div&gt; &lt;div class="ui-radio"&gt; &lt;input type="radio" name="active" value="2" id="2"&gt; &lt;label for="2"&gt;&lt;/label&gt;&lt;/input&gt; &lt;/div&gt; &lt;div class="ui-radio"&gt; &lt;input type="radio" name="active" value="3" id="3"&gt; &lt;label for="3"&gt;&lt;/label&gt;&lt;/input&gt; &lt;/div&gt; &lt;/fieldset&gt; &lt;div data-role="footer"&gt; &lt;input type="submit" href="#" onclick="setActive(1)"/&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>JavaScript / Ajax call</p> <pre><code>function setActive(formid) { $.ajax( { type:'POST', url:'active.php', data:$('#activeForm'+formid).serialize(), success:function(response) { } } ); } </code></pre> <p>PHP code:</p> <pre><code>session_start(); include('connectToDb.php'); $id = $_SESSION['id']; if (isset($_POST['active'])) { $formValue = $_POST['active']; mail('my@mail.com','Test',$formValue,'From: dummy@mail.com'); mysql_query(/* UPDATE MySQL */); header("Location: main.php"); } else { mail('my@mail.com','Test','No data recieved!','From: dummy@mail.com'); } </code></pre> <p>So it works up until the <code>if (isset($_POST['active']))</code> but then mails me that no data was recieved. I already have 2 similar forms on the same page and they are way bigger and has no problems running. Can't figure out what I did wrong here.</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.
 

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