Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try to change the <code>$.post()</code> call into this:</p> <pre><code>$.ajax({ type: "POST", url: "join.php", data: dataString, success: function(data) { alert ("Success: "+ data); } }); </code></pre> <p>And, at the beginning of PHP code, place this:</p> <pre><code>var_dump($_POST); </code></pre> <p>This way, the alert message will display the data received from PHP.</p> <h2>UPDATE:</h2> <p>Since I see nobody here is seeing the hugest security risk with that code, I add it here:</p> <p>Be very sure that you pass every single string from post through <code>mysql_real_escape_string()</code> before adding it inside the query!</p> <p>What if anybody posts this as his email address??:</p> <pre><code>'); DROP TABLE clients; -- </code></pre> <h2>UPDATE:</h2> <p>I double-checked documentation of <code>jQuery.ajax()</code> and <code>jQuery.post()</code>. While <code>.post()</code> is just a shortcut for <code>.ajax()</code>, their syntax is different:</p> <pre><code>jQuery.post( url [, data] [, success(data, textStatus, jqXHR)] [, dataType] ) jQuery.ajax( settings ) </code></pre> <p>(updated code above too).</p> <h2>UPDATE:</h2> <p>Try this code, that should work "out of the box":</p> <p>The JavaScript:</p> <pre><code>$(document).ready(function(){ $(".submit").click(function() { $('.error').hide(); var studentEmail = $("input#studentEmail").val(); if (studentEmail == "") { $("label#studentEmail_error").show(); $("input#studentEmail").focus(); return false; } var dataString = { studentEmail : studentEmail, studentPassword : $("#studentPassword").val(), parentEmail : $("#parentEmail").val(), parentPassword : $("#parentPassword").val(), studentFirstName : $("#studentFirstName").val(), studentLastName : $("#studentLastName").val(), studentPhone : $("#studentPhone").val(), parentFirstName : $("#parentFirstName").val(), parentLastName : $("#parentLastName").val(), parentPhone : $("#parentPhone").val(), }; $.ajax({ type: "POST", url: "join.php", data: dataString, success: function(data) { alert ("success: "+ data); } }); return false; }); }); </code></pre> <p>The PHP code</p> <pre><code>var_dump($_POST); echo "\n\n"; // Some white space here if($_POST) { $connection = mysql_connect("localhost","XXXX","XXXX"); if(!$connection) { die("Database connection failed: ". mysql_error()); } if (!mysql_select_db("XXXX",$connection)) { die("Database selection failed: " . mysql_error()); } // Read data from POST $studentEmail = mysql_real_escape_string($_POST['studentEmail']); $studentPassword = mysql_real_escape_string($_POST['studentPassword']); $parentEmail = mysql_real_escape_string($_POST['parentEmail']); $parentPassword = mysql_real_escape_string($_POST['parentPassword']); $studentFirstName = mysql_real_escape_string($_POST['studentFirstName']); $studentLastName = mysql_real_escape_string($_POST['studentLastName']); $studentPhone = mysql_real_escape_string($_POST['studentPhone']); $parentFirstName = mysql_real_escape_string($_POST['parentFirstName']); $parentLastName = mysql_real_escape_string($_POST['parentLastName']); $parentPhone = mysql_real_escape_string($_POST['parentPhone']); $sql = "INSERT INTO clients ". "(`studentEmail`, `studentPassword`, `parentEmail`, `parentPassword`, ". "`studentFirstName`, `studentLastName`, `studentPhone`, `parentFirstName`, ". "`parentLastName`, `parentPhone`) ". " VALUES ('$studentEmail', '$studentPassword', '$parentEmail', ". "'$parentPassword', '$studentFirstName', '$studentLastName', ". "'$studentPhone', '$parentFirstName', '$parentLastName', '$parentPhone')"; $result = mysql_query($sql); if ($result) { echo "Database query successful!"; } else { die("Database query failed: " . mysql_error()); } } </code></pre>
    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