Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:52:18+00:00 2026-05-27T16:52:18+00:00

I have created a registration system that uses AJAX to process the form so

  • 0

I have created a registration system that uses AJAX to process the form so that I can return false. The relevant js is the top block of code. I pass this data to join.php, which sends it to the database. I run a check in join.php to make sure that nobody with a duplicate email has already signed up. As you can see, if the email already exists, I want to insert a message using javascript. Instead of reading the script tags, it simply pastes them into my alert in plaintext…so my alert has the datastring and then actually says the code <script>...</script>. How can I get this js to process instead?

Javascript:

$(".submit").click(function() {  
        var dataString = {
            school : $("#school").val(),
            studentEmail : $("#studentEmail").val(),
            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 ("data sent: "+ data);
            }
        });
        return false;
    }
});

join.php

if($_POST) {
    $school             = mysql_real_escape_string($_POST['school']);
    $studentEmail       = mysql_real_escape_string($_POST['studentEmail']);
    $parentEmail        = mysql_real_escape_string($_POST['parentEmail']);
    $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']);

    $check = mysql_query("SELECT studentEmail FROM clients WHERE  studentEmail = '{$studentEmail}';");
    $num = mysql_num_rows($check);


    if (($num) == 0) {

        $sql = "INSERT INTO clients ".
            "(`studentEmail`, `studentPassword`, `parentEmail`, `parentPassword`, ".
            "`studentFirstName`, `studentLastName`, `studentPhone`, `parentFirstName`, ".
            "`parentLastName`, `parentPhone`, `school`) ".
            " VALUES ('$studentEmail', '$studentPassword', '$parentEmail', ".
            "'$parentPassword', '$studentFirstName', '$studentLastName', ".
            "'$studentPhone', '$parentFirstName', '$parentLastName', '$parentPhone', '$school')";

        $result = mysql_query($sql);
        if ($result) { 
            echo "Database query successful!";
        }
        else {
            die("Database query failed: " . mysql_error()); 
        }

        include "emails/signUp.php";
    }
    else {
        echo 'FAIL

        <script>
            $(".formErrorMessage").html("Email already exists");
        </script>';
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:52:19+00:00Added an answer on May 27, 2026 at 4:52 pm

    The alert shows your script block because you’ve got this in your success handler:

    alert ("data sent: "+ data);
    

    Data is going to be whatever text you output in your PHP. If you want to have variable behavior based on whether your request was successful or not, I’d recommend that your PHP returns JSON containing a success flag and the message. Your JavaScript callback would then look like this:

    function(data) {
        if (data.success) {
            alert ("data sent: "+ data.message);
        } else {
            $(".formErrorMessage").text(data.message);
        }
    }
    

    Your PHP should then change your content-type to JSON:

    header('Content-Type: application/json');
    

    … and your echos would change to something like this:

    echo '{"success": false, "message": "Email already exists."}';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a registration page using CI that works fine. However, I encoded
I have created Facebook registration page, What i want to do is user can
I have created a registration form in silverlight 4, where i have a large
I have created a registration/login system for my members area. Once the user has
So, if a login/registration system is created, so that when the user logs in,
I have created a PHP-script to update a web server that is live inside
I have created a UserControl that has a ListView in it. The ListView is
I have created a few small flash widgets that stream .mp3 audio from an
i have created a workflow activity that do give the item creater of a
I already have a simple registration system in place using php and mysql. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.