SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

Storing signup details in mysql table using PHP

Here we will collect the signup details from the member and pass it through a validation process. The member enters his/her signup details in form in the part I of the tutorial.

In the validation we will check userid, email address are in correct format or not. We will also see if userid is already there in the signup table so we will ask the member to go for another userid. If all the validation passes then we will insert the record to the table and ask the member to login. You can combine our login script as next step in the signup script. Both the scripts/ tutorials uses common table so you can use it as a single script to learn how such a system works.

Related Tutorial
PHP Login script
PHP Login Logout
Note that we have assumed that the register_global is Off and all the variables are by default not available for the signupck.php page to use. So we have to use $_post['userid'] to get the values first and then go for validating and inserting. To know more on register global check this tutorial.

Also we have modified the script and using ctype_alnum function to check the userid for alphanumeric data only. You can use your own validation as per requirement. The basic intention is to explain how a signup script is to be developed.

$userid=$_POST['userid'];
$password=$_POST['password'];
$password2=$_POST['password2'];
$agree=$_POST['agree'];
$todo=$_POST['todo'];
$email=$_POST['email'];
$name=$_POST['name'];
$sex=$_POST['sex'];

if(isset($todo) and $todo=="post"){

$status = "OK";
$msg="";

// if userid is less than 3 char then status is not ok
if(!isset($userid) or strlen($userid) <3){
$msg=$msg."User id should be =3 or more than 3 char length<BR>";
$status= "NOTOK";}

if(!ctype_alnum($userid)){
$msg=$msg."User id should contain alphanumeric chars only<BR>";
$status= "NOTOK";}

if(mysql_num_rows(mysql_query("SELECT userid FROM plus_signup WHERE userid = '$userid'"))){
$msg=$msg."Userid already exists. Please try another one<BR>";
$status= "NOTOK";}


if ( strlen($password) < 3 ){
$msg=$msg."Password must be more than 3 char legth<BR>";
$status= "NOTOK";}


if ( $password <> $password2 ){
$msg=$msg."Both passwords are not matching<BR>";
$status= "NOTOK";}


if ($agree<>"yes") {
$msg=$msg."You must agree to terms and conditions<BR>";
$status= "NOTOK";}

if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>"; }else{ // if all validations are passed.
$query=mysql_query("insert into plus_signup(userid,password,email,name,sex) values('$userid','$password','$email','$name','$sex')");
echo "<font face='Verdana' size='2' color=green>Welcome, You have successfully signed up<br><br><a href=login.php>Click here to login</a><br></font>";
}
}

Download the php script (only )for this tutorial ( For PHP version 4 & not for 5 or above)

Download PHP signup with login script

Download Modified PHP signup with login script if register_global is off for PHP 5 ( For PHP version 5 or above only).
This is a basic script only for easy understanding
Read the tutorial on online membership management script with encrypted password system

Discuss this tutorial at forum


Further readings
Online membership management script
Posting Activation key for lost encrypted password to the email address
Creating a signup page and storing member details in MySQL
Storing signup data in a table
Collecting the data if register global is off for signup script
Changing or updating password by the logged in member
Forgot password feature in member signup script
Basic login form
Login script to authenticate user from a mysql table data
Checking the status of user for login or logged out
Updating member profile inside member area
Finding out who are online








 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
PHP Introduction
Loops & structure
Array
Date & Time
Functions
Form Handling
File Handling
Math Functions
String Functions
GD Functions
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.