Jump to content

User registration


BasiM

Recommended Posts

Hi.

 

Hope someone can help.

 

I have created a form that registers new users. It validates the information first before it inserts the data into the database.

 

Problem : it does not validate the data meaning if u press submit it still processes the data.

it does not insert the data into the database, it prints out error has occurred

 

Please can some assist me.

 

Thanx

 

                         Here is the code

 

                <?php

/*
 * author :[email protected]
 *
 *
 *
 */
include 'connection.php';
 
$title=$_POST['title'];
    $surname=$_POST['surname'];
$name=$_POST['name'];
$id_number=$_POST['id_number'];
$date_of_birth=$_POST['date_of_birth'];
$gender=$_POST['gender'];
$occupation=$_POST['occupation'];
$mobile_number=$_POST['mobile_number'];
$email_add=$_POST['email_add'];
$postal_add=$_POST['postal_add'];
 
 
$titleconfirm="";
$surnameconfirm="";
$nameconfirm="";
$id_numberconfirm="";
$date_of_birthconfirm="";
$genderconfirm="";
$occupationconfirm="";
$mobile_numberconfirm="";
$email_addconfirm="";
$postal_addconfirm="";
$message="";
 
 
if(isset($_POST['submit'])) {
if(!$title){
    $titleconfirm="please select title";
  }
     if(!$surname){
    $surnameconfirm="please enter surname ";
  }
     if(!$name){
      $nameconfirm="please enter name";
  }
if(!$id_number){
      $id_numberconfirm="please enter id number";
  }
 
if(!$date_of_birth){
      $date_of_birthconfirm="please enter date of birth";
  }
 
if(!$gender){
      $genderconfirm="Please select gender";
  }
 
if(!$occupation){
      $occupationconfirm="please enter occupation";
  }
 
  if(!$mobile_number){
      $mobile_numberconfirm="please enter mobile name";
  }
 
  if(!$email_add){
      $email_addconfirm="please enter email address";
  }
 
 
  if(!$postal_add){
      $postal_addconfirm="please enter postal address";
  }
 
if($titleconfirm="please select title" &&
$surnameconfirm="please enter surname" &&
$nameconfirm="please enter name" &&
$id_numberconfirm="please enter id number" &&
$date_of_birthconfirm="please enter date of birth" &&
$genderconfirm="Please select gender" &&
$occupationconfirm="please enter occupation" &&
$mobile_numberconfirm="please enter mobile name" &&
$email_addconfirm="please enter email address" &&
$postal_addconfirm="please enter postal address") 
 
                     {
 
$connection = new createConnection(); // creating connection
 
    $connect = $connection->connectToDatabase(); // connect to database
 
    $connection->selectDatabase(); // select database
     
 
$surname = mysql_real_escape_string($_POST['surname']); 
$name =mysql_real_escape_string($_POST['name']); 
$id_number = mysql_real_escape_string($_POST['id_number']);
$date_of_birth = mysql_real_escape_string($_POST['date_of_birth']);
$gender = mysql_real_escape_string($_POST['gender']);
$occupation = mysql_real_escape_string($_POST['occupation']);
$mobile_number = mysql_real_escape_string($_POST['mobile_number']);
$email_add = mysql_real_escape_string($_POST['email_add']);
 $postal_add = mysql_real_escape_string($_POST['postal_add']);
 
//Insert into database 
 
 
$query = "INSERT INTO `patient`(title,surname,name,id_number,date_of_birth,gender,occupation,mobile_number,email_add,postal_add)
 VALUES ('title','$surname','$name','id_number','$date_of_birth','$gender','$occupation','$mobile_number','$email_add','$postal_add')";
 
  if(mysql_query($query,$con))
        
                {
            $message="<b style='color:lightgreen'>team selection inserted into database</b>";
 
            $message= $message. "<br /><a href='paitent_info.html'>back to selection list</a>";
          }
        else
      
            { die("error occured:". mysql_error());}
      
        }
 
 }
 
 
 if(isset($_POST['clear'])){
$title="";
    $surname="";
$name="";
$id_number="";
$date_of_birth="";
$gender="";
$occupation="";
$mobile_number="";
$email_add="";
$postal_add="";
 
  
 }
  
 
 
 
 
 
 
 
 
  
     
 
  
 
 
?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/283063-user-registration/
Share on other sites

The error occurred message is coming from this line

{ die("error occured:". mysql_error());}

This line is executed because mysql_query() returned false. When this happens it usually indicates there is an error with the query/mysql. The mysql_error() should display the actual error from MySQL.

 

So is that the full complete error message you are getting? In order for use diagnose the problem you need to post the full complete error(s).

Link to comment
https://forums.phpfreaks.com/topic/283063-user-registration/#findComment-1454347
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.