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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:23:09+00:00 2026-05-23T00:23:09+00:00

$error1=”; $error2=”; $error3=”; $error4=”; $error5=”; $error6=”; $yourname=”; $email=”; $email2=”; $password=”; $password2=”; $country=”; if (isset($_POST[‘Registerme’]))

  • 0
 $error1=''; 
 $error2=''; 
$error3=''; 
$error4=''; 
$error5=''; 
$error6='';

$yourname='';
$email='';
$email2='';
$password='';
$password2='';
$country='';

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

$_POST['yourname']=$yourname;
$_POST['email']=$email;
$_POST['email2']=$email2;
$_POST['password']=$password;
$_POST['password2']=$password2;
$_POST['country']=$country;

if($yourname==''){

    $error1='name required';

    } 


if($email==''){

    $error2='email required';

    } 
if($email2==''){

    $error3='required field';

    } 


if($password==''){

    $error4='password required';

    } 


    if($password2==''){

    $error5='required field';

    } 


if($country==''){

    $error6='country required';

    } 



       if(empty($error1) && empty($error2) && empty($error3) && empty($error4) &&     empty($error5) && empty($error6))

      {echo 'mysql query goes here and add the user to database';}

       }///main one

      else {$error1=''; 
     $error2=''; 
         $error3=''; 
         $error4=''; 
          $error5=''; 
            $error6='';}

this is a registration validation script. in my registration form there are two email and password filelds.second fields are for confirmation.i want to check weather user typed same information in that both field.if i want to do that in this script should i use another if statement? or i should use else if? i am confused about that step…

  • 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-23T00:23:10+00:00Added an answer on May 23, 2026 at 12:23 am

    Some comments:

    • You MUST sanitize input! Take a look at best method for sanitizing user input with php.
    • Your assignments: Instead of “$_POST[‘yourname’]=$yourname;” it should be “$yourname=$_POST[‘yourname’];”.
    • You’re using a lot of variables for error control, and after that if all went well you simply forget the error messages in the last else block. Use some kind of array for error strings, and use it!
    • Are you sure you aren’t validating usernames/passwords to not contain spaces or weird characters, or emails to be valid?

    Some sample code…:

    // Simple sanitize function, complete it
    function sanitize_input ($inputstr) {
        return trim(mysql_real_escape_string($inputstr));
    }
    
    if (isset ($_POST['Registerme']) {
        // array of error messages to report
        $error_messages = array();
        $isvalid = true;
    
        // Assignment 
        $yourname = sanitize_input ($_POST['yourname']);
        $email = sanitize_input ($_POST['email']);
        $email2 = sanitize_input ($_POST['email2']);
        $password = sanitize_input ($_POST['password']);
        $password2 = sanitize_input ($_POST['password2']);
        $country = sanitize_input ($_POST['country']);
    
        // Validation
        if (empty ($yourname)) {
            $error_messages[] = "You must provide an username";
        } 
    
        if (empty ($password)) {
            $error_messages[] = "You must provide a password.";
        }
        elseif ($password !== $password2) {
            $error_messages[] = "Passwords do not match.";
        }
    
        // Same for email, you caught the idea
    
        // Finally, execute mysql code if all ok
        if (empty($error_messages)) {
           // Execute mysql code
           isvalid = true;
        }
    }
    
    // After form processing, use isvalid which is false if there are errors
    // and the error_messages array to report errors
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

errors = {} #errorexample errors['id'] += ('error1',) errors['id'] += ('error2',) #works but ugly errors['id']
I have a custom converter to select a Country in a SelectOneMenu component: File:
A python newbie question: I need to do the following try: do-something() except error1:
I have my javascript file: foo.js var FooNS = { T:5, S: FooNS.T+5, //ERROR1
#!/bin/bash grep -q 'string1' abc.txt && sed -i~ s/string1/string2/g abc.txt || echo ERROR1! Exiting...;
Errors that occur deep down in a data access layer or even higher up,
Error message: fatal: git checkout: updating paths is incompatible with switching branches/forcing How to
Error loading script occurs under FireFox 3 if I quickly click different links on
Error : Error 1 bin\Debug\Daemon.exe.manifest;bin\Release\Daemon.exe.manifest is an invalid value for the InputManifest parameter of
Error: Unable to read data from the transport connection: A blocking operation was interrupted

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.