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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:10:01+00:00 2026-05-23T19:10:01+00:00

here is some code that I plan on using in a registration form for

  • 0

here is some code that I plan on using in a registration form for my site

<?php
session_start();
include ("includes/config.php");
if ($Authenticated == False) {
    ?>
    <div id="register">
        <form action="index.php?page=register" method="post">
            <lable id="registerStuff"> Name: </>
                <input id="registerIn" type='text' name='name' maxlength="20" />
                <br/>
                <lable id="registerStuff"> Surname: </>
                    <input id="registerIn" type='text' name='surname' maxlength="20" />
                    <br/>
                    <lable id="registerStuff"> Username: </>
                        <input id="registerIn" type='text' name='username' maxlength="20" />
                        <br/>
                        <lable id="registerStuff"> Password: </>
                            <input id="registerIn" type='password' name='password' maxlength="20" />
                            <br/>
                            <lable id="registerStuff"> Retype Password: </>
                                <input id="registerIn" type='password' name='passwordcheck' maxlength="20" />
                                <br/>
                                <input type='submit' value='Register'>
                                <br/>
                                </form>
                                </div>
                                <?php
                                $name = mysql_real_escape_string($_POST['name']);
                                $surname = mysql_real_escape_string($_POST['surname']);
                                $username = mysql_real_escape_string($_POST['username']);
                                $password = mysql_real_escape_string(md5($_POST['password']));
                                $passwordcheck = mysql_real_escape_string(md5($_POST['passwordcheck']));
                                if ($username OR $password OR $passwordcheck != null) {
                                    if ($password == $passwordcheck) {
                                        $query = "INSERT INTO users (name, surname, username, password) VALUES ('" . $name . "', '" . $surname . "', '" . $username . "', '" . $password . "')";
                                        $result = mysql_query($query);
                                        if (!$result) {
                                            echo "Username wrong";
                                        }
                                    } else {
                                        echo "passwords didnt match";
                                    }
                                }
                            }
                            if ($Authenticated == True) {
                                header("Location: index.php");
                            }
                            ?>

I cant seem to get proper error messages working, I need to check if the 2 passwords entered are identical, I also need to make sure that no blanks can be entered into the DB. If anyone could help me at all it would be much appreciated

  • 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-23T19:10:01+00:00Added an answer on May 23, 2026 at 7:10 pm

    You made quite a common mistake I guess. Most beginners seem to want to write as little code as possible. However, in this case that doesn’t work. You will have to check each variable for emptiness.

    Your code would be correct when you changed your if construct:

    if ($username != "" AND $password != "" AND $passwordcheck != "") {
    
    }
    

    However, to make the code look a bit slighter, it’s probably best to just use the function empty() that returns TRUE if the variable is empty:

    if (!empty($username) AND !empty($password) AND !empty($passwordcheck)) {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given some JS code like that one here: for (var i = 0; i
Here's the situation: We have some generic graphics code that we use for one
We have some old C code here that's built with nmake. Is there an
I have a piece of code here that i really could use some help
I'm looking for something like break for loops. Here's some example code (using Symfony's
I have some code that uses a form.submit() to open up another window when
I have some code that I'm using to get data from a network socket.
Here is some code I could not get to format properly in markdown, this
Here's some code I saw once. Can you see what's wrong with it? [updated]
Here's some Ruby code: puts %x{ pstree #{$$} } # never forks puts %x{

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.