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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:37:59+00:00 2026-05-30T21:37:59+00:00

I have created a user registration form using PHP, a password must be entered

  • 0

I have created a user registration form using PHP, a password must be entered and entered again to check they both match. I have my conditional checks which are run when the form is submitted, if they fail, the form is reloaded empty for the user to fill in. I wanted to do a real time check against the password, and repeatPassword fields, so if they were both entered and did not match a warning displayed instantly, not after the whole form was filled in and submitted.

I have tried doing this using only PHP, I was using JavaScript before but I want to do it all in PHP as I think it will be better and more reliable.

Here is the code I have for my form checking condition:

$firstname=$_POST['fName'];
$surname=$_POST['sName'];
$email=$_POST['emailad'];
$password= md5($_POST['password']);
$repeatpassword= md5($_POST['repeatPassword']);
$secretquestion=$_POST['sQuestion'];
$secretanswer=$_POST['sAnswer'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$address3=$_POST['address3'];
$address4=$_POST['address4'];
$city=$_POST['city'];
$postcode=$_POST['postcode'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];

if(!empty($password)
&& !empty($repeatpassword)
&& !empty($firstname)
&& !empty($surname)
&& !empty($email)
&& ($repeatpassword == $password)
&& !empty($secretquestion)
&& !empty($secretanswer)
&& !empty($address1)
&& !empty($city)
&& !empty($postcode)
&& !empty($phone))
 {


$reg =true;
$sql = "INSERT INTO cryptuser (firstname,surname,email,password, secretq, secreta,
                               address1,address2,address3,address4,city,postcode,phone,mobile)
        VALUES     ('$firstname','$surname','$email','$password','$secretquestion','$secretquestion',
            '$address1','$address2','$address3','$address4','$city','$postcode','$phone','$mobile')"; 

I had code written which I deleted because it was definitely wrong, but I was trying to perform a PHP function, if the password and repeatPassword fields are not empty, check both values are the same, if they are do nothing, else display warning text.

I felt this would work, but I am still trying to get used to php being a server side language.

Any advice would be 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-30T21:38:00+00:00Added an answer on May 30, 2026 at 9:38 pm

    First off, it won’t be “better and more reliable” in PHP than in Javascript. Both languages are Turing-complete and there’s little you can do in one realm you can’t do in the other. You’re only limited by your ability as a coder.

    That said, if you want to do the validation in PHP before the form is submitted, you’re going to have to get the data to the server somehow. Of course, that process is much like submitting a form…

    One means would be to have JS which scrapes the information from the form and makes an AJAX request to the server. If the server says “OK”, then the JS sets the client location to the new page (since the server already received all the contents as part of the validation process, you shouldn’t need to POST them again).

    Moving on, your validation code as you’ve written it above is a very bad idea. See this comic for a fast-and-decent explanation why ( http://bobby-tables.com appears to be down) – imagine what the SQL query would look like if you had that as $_POST['fName'].

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

Sidebar

Related Questions

I have created a user login page and am using Forms Authentication. Users are
I have a registration form that when the user enters in valid registration data
I have a product registration form that allows the user to add additional product
My task is create both login and registration form on one view! I have
I have a user registration form, and wanted to write a human detecting captcha
I have created a multi-page registration form for a website. Due to the page
I am trying to design a user registration form using code igniter 2.1.0. I
I have created a user control to handle adding comments to certain business entities,
I have created a user control (CheckedDirTree) that exposes a CheckedFolder property which in
I have created one user named tuser with create database rights in SQL server

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.