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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:53:42+00:00 2026-05-27T19:53:42+00:00

The code below is meant to insert values into a MySQL Database if the

  • 0

The code below is meant to insert values into a MySQL Database if the passwords match, the username or email isn’t used already. This code is called from ajax on another page. When it is called, the page redirects me to register.php instead of being completed on the backend by ajax. Does anybody see any issues that could be causing this? It doesn’t give me any errors, just a blank white page.

$user = strip_tags(htmlspecialchars($_POST['user'], ENT_QUOTES));
$pass = strip_tags(htmlspecialchars($_POST['pass'], ENT_QUOTES));
$cpass = strip_tags(htmlspecialchars($_POST['cpass'], ENT_QUOTES));
$age = strip_tags(htmlspecialchars($_POST['age'], ENT_QUOTES));
$email = strip_tags(htmlspecialchars($_POST['email'], ENT_QUOTES));
$country = strip_tags(htmlspecialchars($_POST['count'], ENT_QUOTES));
$lang = strip_tags(htmlspecialchars($_POST['lang'], ENT_QUOTES));
$mdpass = md5($pass);
$mdcpass = md5($cpass);
$created = Date("Y-m-d");


$result = mysql_query("SELECT username,email FROM tableName WHERE username = '$user'");
while ($row = mysql_fetch_array($result)) 
{
if ($row['username']>0) {
    echo 'nvuname';
} 
elseif ($row['email']>0)
{
    echo 'nvemail';
}
else
{
    if ($mdpass == $mdcpass && $age>>14) 
    {
        mysql_query("INSERT INTO tableName (username, pword, email,created,admin,rnumenab,autoreload,country,mailenab,updates,lang) VALUES ($user, $mdpass, $email, $created,'0','1','1',$country,'1','0',$lang)");
        echo 'success';
    }
}

JavaScript:

$("#regsubmit").click(function() {
    var action = $("#mainReg").attr('action');
    var form_data = {
        user: $("#user-reg").val(),
        pass: $("#pass-reg").val(),
        cpass: $("#cpass-reg").val(),
        email: $("#email").val(),
        age: $("#age").val()
    };
    $.ajax({
        type: "POST",
        url: action,
        data: form_data,
        success: function(result)
        {
            if(result=='success') {
                $('#register-action').animate({
                    opacity : '-=1',
                    bottom : '-=60%'
                    }, 600);
                $('#register-action-bckgnd').hide();
                $('.message').fadeOut(600);
            } else {
                $('.regerror').fadeIn(600);
            }
        }
    });
    return false;
});

Thanks, and if you see any issues please let me know. Thank you so much!

Also:How do I sanitize my inputs so no HTML tags are included or did the strip_tags do that? Thanks.

EDIT: It now works and submits the page doesn’t reload, but it always returns error instead of success even if I am sure I am using an open email, username. Turns out I had (‘$age’) instead of (‘#age’). Ideas?

  • 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-27T19:53:42+00:00Added an answer on May 27, 2026 at 7:53 pm

    Although I have not seen your javascript, when an ajax call results in a blank page, that normally means the page is being posted normally and not (only…) by ajax.

    You will need to add something like

    event.preventDefault();
    

    or

    return false;
    

    to your javascript click / submit function.

    Edit: Without seeing the html, you are using a click-handler and although that click-handler may return false, that does not mean that the form does not get submitted normally. I would attach the javascript to the form submit-handler instead and prevent the submit.

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

Sidebar

Related Questions

The code I have pasted below is meant to display images on the middle
The code below shows a sample that I've used recently to explain the different
Hi I have this code below which is meant to check that the url
DISCLOSURE: This is homework. The code below is meant to read a command file
The below code is meant to trim my string. Unfortunately it's removing more than
The code below (for running in LinqPad) is meant to parse the foo/skip/bar string
I'm trying to insert multiple rows into MySql with only one INSERT INTO statement
Why is the Child class's converter constructor called in the code below? I mean,
In the below code sample, what does {0:X2} mean? This is from the reflection
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {

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.