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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:23:06+00:00 2026-05-31T05:23:06+00:00

(This is my first try with php) I have a very basic register page.

  • 0

(This is my first try with php)

I have a very basic register page.
http://graves-incorporated.com/test_sites/member_test/register/register.php

* I just remembered PHP code doesn’t show up in the source so here it is:

enter code here
<?php
include('connection.php');

if(isset($_POST['form'])){
    if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['conf_pass']) || empty($_POST['email'])){
        echo '<b>Please fill out all fields.</b>';

    }elseif($_POST['password'] != $_POST['conf_pass']){
        echo '<b>Your Passwords do not match.</b>';
    }else{
        $url = 'http://graves-incorporated.com/test_sites/plantation_park_2012/';
        echo '<META HTTP-EQUIV=Refresh CONTENT="2; URL='.$url.'">';
        echo '<b>Congrats, You are now Registered.</b>';
        mysql_query("INSERT INTO users VALUES(NULL, '$_POST[username]', '$_POST[password]', '$_POST[email]')");     
    }
}
?>

I want to make sure I don’t get duplicate users and/or email addresses in the database. I set up a Unique Key in MySQL for Username and Email, which prevents it, but the user on the actual form doesn’t know that, it still tells them “Congrats, you are signed up” or whatever it says… haha

So what can I add to the php code (and where in the code) that would prevent this?

Thanks for helping this major noob,
Dan Graves

  • 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-31T05:23:06+00:00Added an answer on May 31, 2026 at 5:23 am
    <?php
    include('connection.php');
    
    if(isset($_POST['form'])){
        if(empty($_POST['username']) || empty($_POST['password']) || empty($_POST['conf_pass']) || empty($_POST['email'])){
            echo '<b>Please fill out all fields.</b>';
    
        }elseif($_POST['password'] != $_POST['conf_pass']){
            echo '<b>Your Passwords do not match.</b>';
        }else{
    
            $dup = mysql_query("SELECT username FROM users WHERE username='".$_POST['username']."'");
            if(mysql_num_rows($dup) >0){
                echo '<b>username Already Used.</b>';
            }
            else{
                $url = 'http://graves-incorporated.com/test_sites/plantation_park_2012/';
                echo '<META HTTP-EQUIV=Refresh CONTENT="2; URL='.$url.'">';
    
                $sql = mysql_query("INSERT INTO users VALUES(NULL, '$_POST[username]', '$_POST[password]', '$_POST[email]')");     
                if($sql){
                     echo '<b>Congrats, You are now Registered.</b>';
                }
                else{
                    echo '<b>Error Registeration.</b>';
                }
            }
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off - hello, this is my first Stack Overflow question so I'll try
Using Dozer to map two objects, I have: /** /* This first class uses
Code first: '''this is main structure of my program''' from twisted.web import http from
I have a JSON data like this: { hello: { first:firstvalue, second:secondvalue }, hello2:
This is my first question here, and I will try to follow all the
I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en . I have successfully
I have a PHP script that runs as a background process. This script simply
First off, I'm a complete novice as a web developer. I have a PHP
First of all, I have been a php programmer for a long time and
I have very little experience in web development, so this may be a very

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.