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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:49:49+00:00 2026-06-09T08:49:49+00:00

UPDATE: Code is written as is and will stay that way. However, now it

  • 0

UPDATE:

Code is written as is and will stay that way. However, now it doesn’t submit the data the user wrote in the form to the database. What’s wrong.

Here is the first file. It contains the XML HTTP REQUEST and html form. This file also contains the wild .

 <!DOCTYPE html>

 <html>

<head>

 <?php
 require_once 'core/init.php';
 ?>

    <meta charset="utf-8" />        

    <title></title> 

    <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js">

 //directly below is that wild script tag

 </script>




 <script type="text/javascript">

 function load(thefile, thediv) {

 if (window.XMLHttpRequest) {

xmlhttp = new XMLHttpRequest();

} else {

    xmlhttp = new ActiveXObject ('Microsoft.XMLHTTP');

    }


xmlhttp.onreadystatechange = function () {

if (xmlhttp.readyState==4 && xmlhttp.status==200) {



document.getElementById(thediv).innerHTML = xmlhttp.responseText;   

    }

}   

parameters1 = 'username='+document.getElementById('username').value;
parameters2 = 'email='+document.getElementById('email').value;
parameters3 = 'password='+document.getElementById('password').value;
parameters4 = 'password_again='+document.getElementById('password_again').value;
parameters5 = 'first_name='+document.getElementById('first_name').value;
parameters6 = 'last_name='+document.getElementById('last_name').value;

xmlhttp.open('POST', thefile, true);
xmlhttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
xmlhttp.send(parameters1 + '&' + parameters2 + '&' + parameters3 + '&' + 

    parameters4 + '&' + parameters5 + '&' +parameters6);

 }

 </script>

    </script>   

    <title>Pop Up Sign Up</title>


</head>

    <body>

<div id="popupbox"> 

        <form name="signup" action="" method="post">

            Desired Username:

<input id="username" placeholder="Username" value="<?php echo 

    (isset($desired_username) ? strip_tags($desired_username) : '');?>" type="text" 

    placeholder="Bob123" name="username" size="14" />

            <br />   <br /> 

            Your Email:
            Register
<input id="email" placeholder="jasontanner328@gmail.com" value="<?php echo 

    (isset($desired_email) ? strip_tags($desired_email) : '');?>" type="email" 

    name="email" size="14" />

            <br />   <br /> 

            Your Password:

<input id="password" placeholder="Password" name="password" type="password" 

    size="14" />

            <br />  <br />      

            Your Password Again:

<input id="password_again" placeholder="Password Again" 

    name="password_again" type="password" size="14" />

            <br />  <br />  

            First Name:

<input id="first_name" placeholder="Jason" value="<?php echo 

    (isset($desired_first_name) ? strip_tags($desired_first_name) : '');?>" 

    name="first_name" type="text" size="14" />

            <br />  <br />  

            Last Name:

<input id="last_name" placeholder="Tanner" name="last_name" value="<?php echo 

    (isset($desired_last_name) ? strip_tags($desired_last_name) : '');?>" type="text" 

    size="14" />

            <br />  <br />  

<center><input type="button" name="submit" value="Register" 

    onclick="load('register.php', 'popupbox');" /></center>

        </form>



</div> 



 <span id="result">



 </span>


 </body>

 </html>

Here is the second file that deals with inserting the data into the server and what I want to return after the submit button has been clicked on.

   <?php

require_once 'core/init.php';
logged_in_redirect();
if (empty($_POST) === false) {


$desired_username = $_POST['username'];
$desired_email = $_POST['email'];
$desired_first_name = $_POST['first_name'];
$desired_last_name = $_POST['last_name'];

$required_fields = array 

('username','email','password','password_again','first_name','last_name');

foreach ($_POST as $key=>$value) {

if (empty($value) && in_array($key, $required_fields) === true) {

    $errors[] = 'Fields marked with an asterisk are required.';

break 1;    
                                                                                         }
                                            }

if (empty($errors) === true)    {
if (user_exists($_POST['username']) === true || strlen($_POST ['username']) < 6) {

$errors[] = 'Sorry, the username \''    . $_POST['username'] . '\' is already taken 

or is too short. 6 characters are the minimum.';
                                                                                                                    }

if (preg_match("/\\s/", $_POST ['username']) == true) {
$errors[] = 'Sorry there is a space in your username.';         
                                                                                }

if (strlen($_POST ['password']) < 6)    {
$errors[] = 'Your password must be at least 6 characters';
                                                            }

if ($_POST ['password'] !== $_POST['password_again']) {
$errors[] = 'Make sure both passwords submitted are the same.';     
                                                                                }   

if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
$errors[] = 'A valid email address is required.';
                                                                                                }   

if (email_exists($_POST['email']) === true) {
$errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already in use.';
                                                                    }

if (strlen($_POST ['first_name']) < 2) {
$errors[] = 'Your first name must contain at least two characters.';
                                                  }
if (strlen($_POST ['last_name']) < 2) {
$errors[] = 'Your last name must contain at least two characters.';
                                                  } }
                                                    } else {


//if (isset($_GET['success']) && empty($_GET['success'])) {

//echo 'You have successfully registered. Please check your email to activate your 

account.';  

//  } else {

if (empty ($_POST) === false && empty($errors) === true){
    $register_data = array(
    'username'              => $_POST['username'],      
    'password'              => $_POST['password'],
    'first_name'            => $_POST['first_name'],
    'last_name'             => $_POST['last_name'],
    'email'                     => $_POST['email'],
    'email_code'            => md5($_POST['username'] + microtime())
                                 );

    register_user($register_data);


echo 'WIN';                                     



//      header('Location: register.php?success');
//      exit();

//  } else 

if (empty($errors) === false){
    echo output_errors($errors);
         }
}}
?>
  • 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-06-09T08:49:51+00:00Added an answer on June 9, 2026 at 8:49 am

    The button on your form is type="submit"; This will submit the form and redirect the page, unless you have it return false; in the onclick attribute. I would suggest, rather, to change the button to a regular button instead of a submit-button:

    <input type="button" name="submit" value="Register" onclick="load('register.php', 'result');" />
    

    This change will stop your page from redirecting after submitting the form.

    EDIT: After reviewing the full code, the POST-page looks like it has a logic error in the processing (and a few syntax errors; see my comment on the question regarding closing curly braces).

    The if (empty($errors) === true) { block ends with an } else { and inside the else-block you output that the user has successfully registered. Translated, this means “if there is an initial error, tell the user they successfully registered.” Instead, change everything after (and including) the } else { to:

    if (!empty($_POST) && empty($errors)) {
        // the form has been submitted and there are no errors
        echo 'You have successfully registered. Please check your email to activate your account.';
        $register_data = array(
        'username'              => $_POST['username'],      
        'password'              => $_POST['password'],
        'first_name'            => $_POST['first_name'],
        'last_name'             => $_POST['last_name'],
        'email'                     => $_POST['email'],
        'email_code'            => md5($_POST['username'] + microtime())
                                     );
        register_user($register_data);
    } else if (!empty($errors)) {
        // there are errors =[
        echo output_errors($errors);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to update some hibernate code that was written by someone else
Is there any way to get the actual data that will be sent when
I have the following code: UPDATE myTable SET Col1 = @Value However, I have
I have a .net website written in C# and will make functionalities that other
I came across some code written in VS7.1 and now I'm trying to get
UPDATE!! I am sorry for this post, the code I had written for this
I currently use Zend_Db to manage my queries. I've written already code that preforms
I am trying to update code via Linq, but I am getting this error:
I am using following steps to update code on server after login to server:
suppose you update your code to revision 10 which is broken. You want to

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.