⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 add_customer.php

📁 《PHP专业项目实例开发》源代码
💻 PHP
字号:
<?php

if ( empty($name) )        {  die("name left blank");  }
if ( empty($email) )       {  die("email left blank"); }
if ( empty($address) )     {  die("address left blank");  }
if ( empty($birth_day) )   {  die("birth day left blank"); }
if ( empty($birth_month)) {  die("birth month left blank"); }
if ( empty($birth_year) )  {  die("birth year left blank");  }
if ( empty($gender))       {  die("gender left blank");  }
if (empty($password))      {  die ("Password empty."); }


$host="";
$database="books";
$dbusername="root";
$dbpassword="";

$x=mysql_connect($host,$dbusername,$dbpassword);
$x1=mysql_select_db($database);

  $query="select email from newsmail where email='".$email."'";
  $result=mysql_query($query);
  if($row=mysql_fetch_array($result))
  {
    die(" Sorry that user " .$email. " already exists !  <br>"); 
  }

  $query="select MAX(customerid) as customerid from customerinfo";
  $result=mysql_query($query);
  if($row=mysql_fetch_array($result))
  {
   $customerid = ++$row["customerid"];    
  }
  else
  {
   die("something wrong with the customerinfo table!");
  }
  $dob = $birth_year . "-" . $birth_month . "-" . $birth_day;
  
  $query="INSERT into customerinfo VALUES('".$customerid."','".$name."','".$address."','".$dob."','".$gender."')";
  $result=mysql_query($query);
  if (!($result)) 
  {
   die(" User personal information could not be stored"); 
  }

  $query ="INSERT into newsmail VALUES('".$name."','".$email."','".$customerid."')";
  $result=mysql_query($query);

  if (!($result)) 
  { 
  die("User e-mail information could not be stored ");
  }

  $query ="INSERT into login VALUES('".$customerid."','".$email."','".md5($password)."')";
  $result=mysql_query($query);

  if (!($result)) 
  { 
  die(" User authentification information could not be stored");
  }
  
  echo " <center>New User Added Successfully </center><br>";
  echo "  <hr><br><br>";
  echo "  Customerid/Login ID : <b>".$customerid."</b><br>";
  if ($gender=="Male") 
  {
   echo "Name : Mr. ";
  } 
  else 
  { 
   echo "Name : Ms. ";
  }
  echo $name,"<br>";
  echo "  email : ",$email,"<br>";
  echo "  Password : ";
  for ($i=0;$i<strlen($password);$i++)  {echo "*";}
  echo "<br>\n";
  echo "  Address : ",$address,"<br>";
  
  
?>
<A href="login.htm">Proceed to login page</a>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -