0

登録ページを作成していて、それをサーバーにアップロードしたところです。登録ボタンを押すと、ページが更新されて何もしません。

私のPHPコードは次のとおりです。

<?php

$error = "";
$firstname = "";
$lastname = "";
$email = "";
$password = "";
$confirmpassword = "";
$day = "";
$month = "";
$year = "";
$gender = "";

if (isset ($_POST['firstname'])){

 $firstname = $_POST['firstname'];
 $lastname = $_POST['lastname'];
 $email = $_POST['email'];
 $password = $_POST['password'];
 $confirmpassword = $_POST['confirmpassword'];
 $day = $_POST['day'];
 $month = $_POST['month'];
 $year = $_POST['year'];
 $gender = $_POST['gender'];

 $firstname = stripslashes($firstname);
 $lastname = stripslashes($lastname);
 $email = stripslashes($email);
 $password = stripslashes($password);
 $confirmpassword = stripslashes($confirmpassword);
 $day = stripslashes($day);
 $month = stripslashes($month);
 $year = stripslashes($year); 
 $gender = stripslashes($gender); 

 $firstname = strip_tags($firstname);
 $lastname = strip_tags($lastname);
 $email = strip_tags($email);
 $password = strip_tags($password);
 $confirmpassword = strip_tags($confirmpassword);
 $day = strip_tags($day);
 $month = strip_tags($month);
 $year = strip_tags($year);
 $gender = strip_tags($gender);

 include_once "includes/mysql_connection.php";
 $emailChecker = mysql_real_escape_string($email);
 $sql_email_check = mysql_query("SELECT email FROM users WHERE email='$emailChecker'");
 $email_check = mysql_num_rows($sql_email_check); 

 if ((!$firstname) || (!$lastname) || (!$email) || (!$password) || (!$confirmpassword) || (!$day) || (!$month) || (!$year) || (!$gender)) { 

 $error = 'You missed out the following information:<br/>';

 if(!$firstname){ 
   $error .= 'Firstname<br/>';
 } 
 if(!$lastname){ 
   $error .= 'Lastname<br/>';
 } 
 if(!$email){ 
   $error .= 'Email<br/>';
 }  
 if(!$password){ 
   $error .= 'Password<br/>';      
 }
 if(!$confirmpassword){ 
   $error .= 'Confirm Password<br/>';        
 } 
 if(!$day){ 
   $error .= 'Day<br/>';        
 }      
 if(!$month){ 
   $error .= 'Month<br/>';      
 }
 if(!$year){ 
   $error .= 'Year<br/>';        
 }  
 if(!$gender){ 
   $error .= 'Gender<br/>';      
 }  

 } else if ($password != $confirm) {
          $error = 'Your password\'s do not match.';         
 } else if ($email_check > 0){ 
          $error = "The email address you supplied is already in use."; 

 } else { 
 $firstname = mysql_real_escape_string($firstname);
 $lastname = mysql_real_escape_string($lastname);
 $email = mysql_real_escape_string($email);
 $password = mysql_real_escape_string($password);
 $day = mysql_real_escape_string($day);
 $month = mysql_real_escape_string($month);
 $year = mysql_real_escape_string($year);
 $gender = mysql_real_escape_string($gender);

 $db_password = md5($password); 

 $sql = mysql_query("INSERT INTO users (firstname, lastname, email, password, day, month, year, gender) 
 VALUES('$firstname','$lastname','$email','$db_password','$day','$month','$year','$gender')")  
 or die (mysql_error());

 $id = mysql_insert_id();

 mkdir("members/$id", 0777);    


$to = "$email";

$from = "donotreply@website.com";
$subject = "Activate your  account";

$message = "


";


$headers  = "From: $from\r\n";
$headers .= "Content-type: text\r\n";

mail($to, $subject, $message, $headers);



$confirmationmessage = "<h2>Welcome to our website</h2><br />
   You've been sent an email to $email - this email will contain an activation link!
   <br />
   ";


   include_once 'includes/message.php'; 

   exit();

   }

} else {

  $error = "";
  $firstname = "";
  $lastname = "";
  $email = "";
  $password = "";
  $confirmpassword = "";
  $day = "";
  $month = "";
  $year = "";
  $gender = "";

}

?>

何が起きているのか理解できません。HTML が必要かどうか尋ねてください。

4

0 に答える 0