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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:00:42+00:00 2026-05-24T03:00:42+00:00

When a user registers on my site, I want to be able to check

  • 0

When a user registers on my site, I want to be able to check my sql table/records and see if that email and username they are registering with has already been used. Below is the code I use for returning errors if any of the fields are left blank:

//Input Validations
if($user_name == '') {
    $errmsg_arr[] = 'Username missing';
    $errflag = true;
}
if($user_password == '') {
    $errmsg_arr[] = 'Username Password missing';
    $errflag = true;
}
if($insp_name == '') {
    $errmsg_arr[] = 'Inspector Name missing';
    $errflag = true;
}
if($insp_email == '') {
    $errmsg_arr[] = 'Inspector Email missing';
    $errflag = true;
}
if($confirm_password == '') {
    $errmsg_arr[] = 'Confirm Password missing';
    $errflag = true;
}       

if ($user_password != $confirm_password) { 
        $errmsg_arr[] = 'The password which you have entered do not match';
    $errflag = true;
   }

//If there are input validations, redirect back to the registration form
if($errflag) {
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
    session_write_close();
    header("location: accountinfo.php");
    exit();
}

I have tried something like this to check my sql:

$result=mysql_query("SELECT email FROM members WHERE `email` = '$insp_email'" ); 
$exist = mysql_fetch_row($result); 
    if ($exist == 1) { 
       $errmsg_arr[] = 'That email is already registered.';
    $errflag = true;
       }

That doesn’t work though. I know it is probably an easy solution, I just can’t see it lol. What I would like is to check the sql for the email and username. If either of those 2 exist already in the sql, then I want to redirect back to the registration page, and display a message saying “That email or username is already in use”

Thanks!

Ok I have it working now and it’s just what I wanted. But another problem I noticed is if there is an error (blank field, username already in use) when it redirects back to the registration page, it doesn’t display the error or explain why the user was sent back to the registration page. Again my code for that part is below:

//If there are input validations, redirect back to the registration form
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: accountinfo.php");
exit();
}
  • 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-24T03:00:43+00:00Added an answer on May 24, 2026 at 3:00 am
    $result=mysql_query("SELECT email FROM members WHERE `email` = '$insp_email' or username='$username' LIMIT 1" ); 
    $exist = mysql_fetch_row($result); 
        if ($exist !==false ) { 
           $errmsg_arr[] = 'That email is already registered.';
        $errflag = true;
           }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have confirmation email that is sent after user registers. Now, I want admin
I want to make an email confirmation registration, so that when the user registers
When a user registers with my site I want to offer them a login
Say a user registers for your site, you hash the password they have chosen
I'm trying to modify the way FOSUSerBundle validates the username/email when the user registers,
The main site sends a registration email and I do not want that email
Basically, I have a CodeIgniter site that registers users through this url: http://website.com/user/register/1 Unfortunately,
This is the standard scenario: User registers on the site User receives an account
I want to create sub-domains using PHP on the fly. Suppose a user registers
I have a script that registers users based on their user input. This uses

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.