|
|
|
ช่วยที่คำ สั่งให้ตรวจการคอนเฟิร์มของรหัสผ่านโชว์ว่ารหัสไม่ตรงกันแต่ว่ายังบันทึกข้อมูลอยู่ |
|
|
|
|
|
|
|
หน้า Registration
Code (PHP)
<html>
<head>
<title>Registration </title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250"></head>
<br><br>
<center><font color="#0000FF">Register</center>
<body>
<center>
<form name="reg_form" id="reg_form" method="post" action="confirm.php">
<table>
<tr><td colspan="2"><?php echo isset($_GET["msg"])?$_GET["msg"]:"";?>
</td></tr>
<tr><td>Username</td><td><input type="text" name="username" id="username" />
</td></tr>
<tr><td>Password</td><td><input type="password" name="password" id="password" />
</td></tr>
<tr><td>confirm</td><td><input type="password" name="confirm" id="confirm" />
</td></tr>
<tr><td>Name</td><td><input type="text" name="name" id="name" />
</td></tr>
<tr><td>Tel</td><td><input type="text" name="tel" id="tel" />
</td></tr>
<tr><td>Phone</td><td><input type="text" name="phone" id="phone" />
</td></tr>
<tr><td></td><td><br><input name="Reset" type="reset" id="reset" value="Reset" /> <input name="OK" type="submit" id="submit" value="OK" /></td></tr>
</table>
<a href="home.php">Home</a>
</form>
</center>
</body>
</html>
หน้าConfirm
<?php
$host="localhost";
$user="root";
$pass="makoto";
$link=mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db("rayban",$link);
$query="SELECT * FROM users WHERE username='".mysql_escape_string($username)."'";
$username=isset($_POST["username"])?$_POST["username"]:"";
$password=isset($_POST["password"])?$_POST["password"]:"";
$confirm=isset($_POST["confirm"])?$_POST["confirm"]:"";
$name=isset($_POST["name"])?$_POST["name"]:"";
$tel=isset($_POST["tel"])?$_POST["tel"]:"";
$phone=isset($_POST["phone"])?$_POST["phone"]:"";
if(!empty($username)&&!empty($password)&&!empty($name)&&!empty($tel)&&!empty($phone)){
if($password!=$confirm)
header("location:registration.php?msg=Password does not be match.");
$result=mysql_query($query);
//count no of rows
$count=mysql_num_rows($result);
if($count==1){
header("location:registration.php?msg=username already exists");
}
else
{
$qry="INSERT INTO users(username,password,name,tel,phone)VALUES('".mysql_escape_string($username)."'
,'".mysql_escape_string($password)."','".mysql_escape_string($name)."','".mysql_escape_string($tel)."','".mysql_escape_string($phone)."')";
mysql_query($qry);
echo "You are successfully registered.";
echo "<br> Go to <a href='login.php'>login</a>";
}
mysql_close($link);
}
else
{
header("location:registration.php?msg=Please complete the form below!.");
}
?>
Tag : PHP, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2014-01-12 21:11:48 |
By :
OpTioN |
View :
617 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
header("location:registration.php?msg=Password does not be match.");
exit();
เพิ่ม exit(); เข้าไปด้วยครับ
|
|
|
|
|
Date :
2014-01-12 22:22:21 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|