<?php
require 'core.inc.php';
require 'connect.inc.php';
if(!loggedin()){
if(
isset($_POST['username']) &&
isset($_POST['password']) &&
isset($_POST['password_again']) &&
isset($_POST['firstname']) &&
isset($_POST['surname'])
){
$username = $_POST['username'];
$password = $_POST['password'];
$password_hash = md5($password);
$password_again = $_POST['password_again'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
if(
!empty ($username) &&
!empty ($password) &&
!empty ($password_again) &&
!empty ($firstname) &&
!empty ($surname)
){
if($password == $password_again){
$query = "SELECT username FROM users WHERE username = '$username'";
$query_run = mysql_query($query);
if(mysql_num_rows($query_run)==1){
echo 'Sorry..! This user name '.$username.' already exist.<br/> <br>Pleasetry with any other.';
}else{
$query = "INSERT INTO users VALUES ('', '$username', '$password_hash','$firstname', '$surname')";
if($query_run = mysql_query($query)){
header('Location: register_success.php');
}
}
}else{
echo 'Password is not matching.<br> Please enter again same password.'
}
}else{
echo 'All fields are required. Thanks';
}
}
?>
<form action="register.php" method="POST">
Username:<br> <input type ="text" name="username" value = "<?php echo $username; ?>"><br><br>
Password:<br> <input type ="password" name="password"><br><br>
Password Again: <br> <input type="password" name="password_again"><br><br>
First Name:<br> <input type="text" name="firstname" value = "<?php echo $firstname; ?>"><br/><br>
Sur Name:<br> <input type="text" name="surname" value = "<?php echo $surname; ?>"><br><br>
<input type="submit" value="Register" >
</form>
<?php
}else if(loggedin()){
echo 'You\'re logged in.';
}
?>
次のエラーが表示されます: 通知: Undefined index: HTTP_REFERER in C:\xampp\htdocs\core.inc.php 行 5
Undefined variable: username in C:\xampp\htdocs\register.php on line 46
Notice : Undefined variable: 49行目の C:\xampp \htdocs\register.phpの名通知: 未定義の変数: 50行目のC:\xampp\htdocs\register.phpの姓