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

  • Home
  • SEARCH
  • 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 8312285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:06:44+00:00 2026-06-08T20:06:44+00:00

This is my registration code. Once I enter the fields in the form it

  • 0

This is my registration code.

Once I enter the fields in the form it shows me registration successful but adds blank data in my database table. It adds number 0 in my mobileno column.

Please help me here asap

include ('database_connection.php');

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

$error = array();//Declare An Array to store any error message  

if (empty($_POST['mobileno'])) {//if no name has been supplied 
    $error[] = 'Please Enter a Mobile Number ';//add to array "error"
} else {
    $name = $_POST['mobileno'];//else assign it a variable
}
if (empty($_POST['fname'])) {//if no name has been supplied 
    $error[] = 'Please Enter a First name ';//add to array "error"
} else {
    $name = $_POST['fname'];//else assign it a variable
}
if (empty($_POST['lname'])) {//if no name has been supplied 
    $error[] = 'Please Enter a Last name ';//add to array "error"
} else {
    $name = $_POST['lname'];//else assign it a variable
}
if (empty($_POST['email'])) {
    $error[] = 'Please Enter your Email ';
} else {


    if (preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-    Z0-9\._-]+)+$/", $_POST['email'])) {
       //regular expression for email validation
        $Email = $_POST['email'];
    } else {
         $error[] = 'Your EMail Address is invalid  ';
    }


}


if (empty($_POST['passwd1'])) {
    $error[] = 'Please Enter Your Password ';
} else {
    $Password = $_POST['passwd1'];
}
if (empty($_POST['passwd2'])) {
    $error[] = 'Please Verify Your Password ';
} else {
    $Password = $_POST['passwd2'];
}

if (empty($error)) //send to Database if there's no error '

{ //If everything's OK...

    // Make sure the mobile no is available:
    $query_verify_mobileno = "SELECT * FROM userdtls WHERE mobileno = '$mobileno'";
    $result_verify_mobileno = mysqli_query($dbc, $query_verify_mobileno);
    if (!$result_verify_mobileno) 
    {//if the Query Failed ,similar to if($result_verify_mobileno==false)
        echo ' Database Error Occured ';
    }

    if (mysqli_num_rows($result_verify_mobileno) == 0) { // IF no previous user is using this number .


        // Create a unique  activation code:
       $activation = md5(uniqid(rand(), true));


        $query_insert_user = "INSERT INTO userdtls (`mobileno`, `pass`, `fname`, `lname`, `email`, `activation`) VALUES ( '$mobileno', '$passwd1', '$fname', '$lname', '$email', '$activation')";


        $result_insert_user = mysqli_query($dbc, $query_insert_user);
        if (!$result_insert_user) {
            echo 'Query Failed ';
        }

        if (mysqli_affected_rows($dbc) == 1) { //If the Insert Query was successfull.


            // Send the email:
          $message = " To activate your account, please click on this link:\n\n";
            $message .= WEBSITE_URL . '/activate.php?email=' . urlencode($Email) . "&key=$activation";
            mail($Email, 'Registration Confirmation', $message, 'From: rahul19dj@gmail.com'); 

            // Flush the buffered output.


            // Finish the page:
            echo '<div class="success">Thank you for registering! A confirmation email has been sent to '.$email.' Please click on the Activation Link to Activate your account </div>';


        } else { // If it did not run OK.
            echo '<div class="errormsgbox">You could not be registered due to a system error. We apologize for any inconvenience.</div>';
        }

    } else { // The mobile number is not available.
        echo '<div class="errormsgbox" >That mobile number has already been registered.</div>';
    }

} else {//If the "error" array contains error msg , display them



 echo '<div class="errormsgbox"> <ol>';
    foreach ($error as $key => $values) {

        echo '  <li>'.$values.'</li>';



    }
    echo '</ol></div>';

}

mysqli_close($dbc);//Close the DB Connection

} // End of the main Submit conditional.
  • 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-08T20:06:45+00:00Added an answer on June 8, 2026 at 8:06 pm

    You’re assigning all of your variables, except $email to $name overwriting each one in succession. This is definitely going to cause strange results which are dependant on the data types of each column in your dataase. If mobileno is set to be an int has a default value of 0 a string or empty value will result in you seeing 0 in your dataase.

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

Sidebar

Related Questions

I have this code for displaying content for login and registration in my PHP
I have a registration form where this CSS rules apply. when user submits with
We have a registration system Database and basically what this query does is check
I have a check box in my registration form like this: <form name=reg id=reg
in my project i have one registration form which is developed in C#.net.to this
Let's say I have an user registration form. In this form, I have the
I have a user sign-up form with a registration code field (:reg_code). I have
i'm trying to do this: #region COM Registration Methods /// <summary> /// Performs COM
I'm following this tutorial: http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ I've managed to utilize the tut to access and
The workflow requested by customer is something like this : The user on registration

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.