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 7062461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:35:48+00:00 2026-05-28T04:35:48+00:00

I built a basic form with ajax validation and page redirection with PHP and

  • 0

I built a basic form with ajax validation and page redirection with PHP and jQuery. This was working fine a few days back. I have come back to it and the ajax seems to have stopped working. At the moment the ajax is just checking a test var and echoing back data. It is really bugging me as it working fine initially! Seems strange as I cannot spot anything obvious, hoping some fresh eyes can help.

The ajax has stopped sending data across so I click submit and the ajax sends nothing so my if() does not do anything! I get the form values fine. Tried with basic ajax and alerts, something strange seems to be happening.

Hope you can help

 <form id="registerform">
        <ul id="form">
        <li>
        <label for="email">Email:</label><span class="fieldbox"><input type="text" id="email"/></span>
        </li>
        <li>
        <label for="confirmemail">Confirm Email:</label><span class="fieldbox"><input type="text" id="confirmemail"/></span>
        </li>
        <li>
        <label for="password">Password:</label> <span class="fieldbox"> <input type="password" id="password"/></span>
        </li>
        <li>
        <label for="confirmpassword">Confirm Password:</label> <span class="fieldbox"> <input type="confirmpassword" id="confirmpassword"/></span>
        </li>
        <input type="submit" id="register" value="Sign me up!"/>
        </ul>
 </form>



<div id="errorbox"></div>

jQuery:

   $(document).ready(function(){

           $("#register").click(function(){

           var formvalues = [$("#email").val(), $("#confirmemail").val(), $("#password").val(), $("#confirmpassword").val() ];
           var checklength = formvalues[2].length;


                    if(formvalues[0] == "" || formvalues[1] == ""){
                        $('#errorbox').fadeIn('slow');
                        $("#errorbox").html('<p class="errormsg">Please complete email fields.</p><div class="errormsgshodow"></div>');
                         $("#main").shake(3, 5, 600);
                        return false;//stop click function
                    }

                    if(formvalues[2] == "" ||  formvalues[3] == ""){
                       $('#errorbox').fadeIn('slow');
                        $("#errorbox").html('<p class="errormsg">Please complete password fields.</p><div class="errormsgshodow"></div>');
                         $("#main").shake(3, 5, 600);
                        return false;//stop click function
                    }

                   if(formvalues[0] != formvalues[1]){
                        $('#errorbox').fadeIn('slow');
                        $("#errorbox").html('<p class="errormsg">Password field do not match</p><div class="errormsgshodow"></div>');
                         $("#main").shake(3, 5, 600);
                        return false;//stop click function
                    }

                    if(formvalues[2] != formvalues[3]){
                        $('#errorbox').fadeIn('slow');
                        $("#errorbox").html('<p class="errormsg">Password field do not match</p><div class="errormsgshodow"></div>');
                         $("#main").shake(3, 5, 600);
                        return false;//stop click function
                    }

                     if(checklength < 6 || checklength > 6){
                         $('#errorbox').fadeIn('slow');
                         $("#errorbox").html('<p class="errormsg">Password is too long.</p><div class="errormsgshodow"></div>');
                          $("#main").shake(3, 5, 600);
                         return false;//stop click function   
                    }

                    var datastring = 'email=' + formvalues[1] + '&password=' + formvalues[3];

                       $.ajax({
                        type: "POST",
                        url: "signup.php",
                        data: datastring,
                                      success: function(data){
                                         //see redirect script for stuff here
                                         if(data != "error"){
                                         window.location="http://localhost/creativetree/projectboard.php?id="+data;
                                         }else{
                                         $('#errorbox').fadeIn('slow');
                                         $("#errorbox").html('<p class="errormsg">User account already exists with that email.</p><div class="errormsgshodow"></div>');;
                                         }



                                     }

                       });

           });

  });//jquery end






           //shake functions by Amit Dhamu
           jQuery.fn.shake = function(intShakes /*Amount of shakes*/, intDistance /*Shake distance*/, intDuration /*Time duration*/) {
                this.each(function() {
                     $(this).css({position:"relative"});

                     for (var x=1; x<=intShakes; x++) {
                          $(this).animate({left:(intDistance*-1)}, (((intDuration/intShakes)/4)))
                                       .animate({left:intDistance}, ((intDuration/intShakes)/2))
                                       .animate({left:0}, (((intDuration/intShakes)/4)));
                     }
                });
                return this;
           };

And minimal PHP for result:

  <?php


    if(isset($_POST['email'])){

        $email =  $_POST['email'];
        $password =  $_POST['password'];

                    if($email == "test"){
                        echo $email;
                    }else{
                          echo 'error';      
                    }
    }


    ?>
  • 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-28T04:35:49+00:00Added an answer on May 28, 2026 at 4:35 am

    It’s hard to tell without seeing the error you are receiving, but from what I can see, you are not returning anything from your function upon successful validation, so your form will be submitted normally as well.

    You can prevent the form from submitting by using something like:

    $("#registerform").submit(function() {
      return false;
    });
    

    but perhaps returning false from the submit button click handler is enough as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a basic search form that queries one column in one table of
I know this sounds confusing: I have just built some basic prev/next pagination for
I'm trying to build a basic contact form using jQuery. The markup is essentially
I've just built a basic ASP MVC web site for deployment on our intranet.
The ASP.NET MVC 1.0 (final) project template has basic membership built in, but I
The basics have already been answered here . But is there a pre-built PHP
I know this is a basic function of the DataGridView, but for some reason,
I guess this is very basic but since I'm learning .NET by myself, I
I am trying to use FormCheck for MooTools to validate a basic contact form
I have a basic HTML form that gets inserted into a server side div

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.