Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP, AJAX for Signup Form
    text
    copied!<p>I am new to all of this so bare with me. I am trying to set up my first PHP site and I really want to do it the right way. I am working on the form located: <a href="http://www.bwgblog.com/signup" rel="nofollow noreferrer">http://www.bwgblog.com/signup</a>. </p> <p>I have set up the following form:</p> <pre><code> &lt;p&gt;&lt;form action="/signup/register.php" method="post"&gt; &lt;label for="first_name"&gt;First Name&lt;/label&gt; &lt;input type="text" name="first_name" /&gt; &lt;label for="last_name"&gt;Last Name&lt;/label&gt; &lt;input type="text" name="last_name" /&gt; &lt;label for="company"&gt;Company&lt;/label&gt; &lt;input type="text" name="company" /&gt; &lt;label for="job_title"&gt;Job Title&lt;/label&gt; &lt;input type="text" name="job_title" /&gt; &lt;label for="phone"&gt;Phone&lt;/label&gt; &lt;input type="text" name="phone" /&gt; &lt;label for="email"&gt;Email&lt;/label&gt; &lt;input type="text" name="email" /&gt; &lt;label for="username"&gt;Choose a Username&lt;/label&gt; &lt;input type="text" name="username" /&gt; &lt;label for="password"&gt;Choose a Password&lt;/label&gt; &lt;input type="text" name="password" /&gt; &lt;label for="confirm_password"&gt;Confirm Your Password&lt;/label&gt; &lt;input type="text" name="confirm_password" /&gt; &lt;input type="submit" value="Get Started" /&gt; &lt;/form&gt; </code></pre> <p>And here is my PHP page, register.php:</p> <pre><code> &lt;?php ini_set('display_errors', 1); error_reporting(E_ALL); $con = mysql_connect("localhost","*******","******"); //Replace with your actual MySQL DB Username and Password if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("bwgblog", $con); //Replace with your MySQL DB Name $first_name=mysql_real_escape_string($_POST['first_name']); $last_name=mysql_real_escape_string($_POST['last_name']); $company=mysql_real_escape_string($_POST['company']); $job_title=mysql_real_escape_string($_POST['job_title']); $phone=mysql_real_escape_string($_POST['phone']); $email=mysql_real_escape_string($_POST['email']); $username=mysql_real_escape_string($_POST['username']); $password=mysql_real_escape_string($_POST['password']); $confirm_password=mysql_real_escape_string($_POST['confirm_password']); $sql="INSERT INTO members (first_name,last_name,company,job_title,phone,email,username,password,confirm_password) VALUES ('$first_name','$last_name','$company','$job_title','$phone','$email','$username','$password','$confirm_password')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "The form data was successfully added to your database."; mysql_close($con); ?&gt; </code></pre> <p>I am trying to figure out how to add in AJAX such that it gives me two things. 1) The ability for it to check in realtime the username field as that field should be unique, and 2) the ability to have the confirm password field render a green checkmark if it == password field.</p> <p>I have been looking all day for how to do this and can't get a clear look at it. Here is how the files are laid out:</p> <p>signup (folder) -> index.php -> register.html.php -> register.php</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