-2

ユーザーからの入力が必要な登録フォームがあります。フォームは正常に機能していましたが、データベースに値を挿入しません。誰でも私を助けることができますか?

すべてのコードを表示しますが、必要なのは挿入クエリに関するヘルプです。

register.php

<?php require_once('for members/scripts/connect.php'); ?>

<?php
function specializationQuery(){

$specData = mysql_query("SELECT * FROM specialization");

  while($recordJob = mysql_fetch_array($specData)){

     echo'<option value="' . $recordJob['specialization_id'] .  '">' . $recordJob['specialization_name'] . '</option>';

  }


}

 //default value
$message = "Fields Marcked with an [*] are Required";
  $username = "";
  $fname = "";
  $lname = "";
  $specialization = "";
  $email = "";
  $pass1 = "";
  $pass2 = "";
  $governorate="";
  $district = "";
  $village = "";

if(isset($_POST['username'])){
  $username = mysql_real_escape_string($_POST['username']);
  $fname = mysql_real_escape_string($_POST['fname']);
  $lname = mysql_real_escape_string($_POST['lname']);
  $email = mysql_real_escape_string($_POST['email']);
  $pass1 = mysql_real_escape_string($_POST['pass1']);
  $pass2 = mysql_real_escape_string($_POST['pass2']);
  $bdate = mysql_real_escape_string($_POST['birthdate']);


  $specialization = mysql_real_escape_string($_POST['specialization']);
  $governorate = mysql_real_escape_string($_POST['governorate']);
  @$district = mysql_real_escape_string($_POST['district']);
  @$village = mysql_real_escape_string($_POST['village']);


      var_dump($fname);
      var_dump($username);
      var_dump($governorate);
      var_dump($email);

  //error handeling
  if((!$username)||(!$fname)||(!$lname)||(!$email)||(!$pass1)||(!$pass2)||(!$specialization)||(!$governorate)||(!$district)||(!$village)){
  $message = "**** Please insert the Required Fields below ****<br />";

      if($fname == "")
     {
         $message = $message . "Enter First name<br/>";
     }
      if($lname == "")
     {
         $message = $message . "Enter Last name<br/>";
     }

     if( $specialization == 0)
     {
         $message = $message . "Select Your Job<br />";

     }
     if($governorate == 0)
     {
         $message = $message . "Select Your Governorate<br />";
     }

     if($district == '0')
     {
         $message = $message . "Select Your District<br />";
     }
     if($village == '0')
     {
     $message = $message . "Select Your Village<br />";

     }
     if($email == "")
     {
         $message = $message . "Enter Email Adress<br/>";
     }
      if ($username == "") {
        $message = $message . "Enter User Name<br/>";
      }

      if($pass1 == "")
     {
         $message = $message . "Enter password<br/>";
     }

      if($pass2 == "")
     {
         $message = $message . "rechek the password <br/>";
     }


 } 

     elseif(strlen($pass1) <= 8)
    {
         $message = $message . "Your Password must be at least 8 charachters<br />";
    }
   else if($pass1!=$pass2){
   $message = "your password do not match!";
 }
 else
 {
   //securing the data
   $username = preg_replace("#[^0-9a-z]#i","",$username);
   $fname = preg_replace("#[^0-9a-z]#i","",$fname);
   $lname = preg_replace("#[^0-9a-z]#i","",$lname);
   //$pass1 = sha1($pass1);

   $email = mysql_real_escape_string($email);
   // checking for duplicate
   $user_query = mysql_query("SELECT user_name FROM user WHERE user_name = '$username'LIMIT 1") or die("could not check the username");
   $count_username = mysql_num_rows($user_query);

    $email_query = mysql_query("SELECT email_address FROM user WHERE email_address = '$email'LIMIT 1") or die("could not check the email");
   $count_email = mysql_num_rows($email_query);

    if($count_username > 0){
     $message = " your username is alredy in use";
    }elseif($count_email > 0){
      $message = "your email is alredy in use";
    }
   else{

      $query = mysql_query("INSERT INTO user(user_name, first_name, last_name, governorate, district, village, birth_date, email_address, specialization, password, registered_date)VALUES('$username', '$fname', '$lname', '$governorate', '$district', '$village', '$bdate', '$email', '$specialization', '$pass1',  now())")or die("could not insert data"); 




    $message = "you have  now been registered";
    //from the social website


        if ($query) 
       {
       $_SESSION['user_id'] = mysql_insert_id();
       $_SESSION['login'] = 'true';
       $_SESSION['login_user'] = $username;
       }
?>
4

1 に答える 1