|
|
|
รบกวนช่วยหน่อยคับผม วิธีการเก็บค่าที่กรอกลงไป เวลามันเช็คเพื่อเซฟพอไม่ผ่านเงื่อนไขมัน back กับมา แล้วค่าที่กรอกมันหายหมด |
|
|
|
|
|
|
|
ผมทำหน้า register
<table width="613" height="158" border="0" style="width: 400px">
<tbody>
<tr>
<td width="142"> Username</td>
<td width="422">
<input name="txtUsername" type="text" id="txtUsername" size="20"></td>
</tr>
<tr>
<td> Password</td>
<td><input name="txtPassword" type="password" id="txtPassword">
</td>
</tr>
<tr>
<td> Confirm Password</td>
<td><input name="txtConPassword" type="password" id="txtConPassword">
</td>
</tr>
<tr>
<td> Name</td>
<td><input name="txtName" type="text" id="txtName" size="35"></td>
</tr>
<tr>
</tr>
<tr>
<td> Email</td>
<td><input name="txtEmail" type="text" id="txtEmail" size="35" /></td>
</tr>
<tr>
<td>Address</td>
<td><label for="txtAddress"></label>
<textarea name="txtAddress" id="txtAddress" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>Tel.</td>
<td><input name="txtTel" type="text" id="txtTel" size="35" /></td>
</tr>
<tr>
</tr>
</tbody>
</table>
หน้า save
<?
mysql_connect("localhost","root","1234");
mysql_select_db("ชื่อ db");
mysql_query("SET NAMES UTF8");
if(trim($_POST["txtUsername"]) == "")
{
echo "Please input Username!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if(trim($_POST["txtPassword"]) == "")
{
echo "Please input Password!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if($_POST["txtPassword"] != $_POST["txtConPassword"])
{
echo "Password not Match!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if(trim($_POST["txtName"]) == "")
{
echo "Please input Name!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if(trim($_POST["txtEmail"]) == "")
{
echo "Please input Email!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if(trim($_POST["txtTel"]) == "")
{
echo "Please input Tel!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
if(trim($_POST["txtAddress"]) == "")
{
echo "Please input Address!";
echo "<meta http-equiv='refresh' content='1;url=register.php' />";
exit();
}
$strSQL = "SELECT * FROM member WHERE Username = '".trim($_POST['txtUsername'])."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
echo "Username already exists!";
}
else
{
$strSQL = "INSERT INTO member (Username,Password,Name,Email,Status,SID,Active,Tel,Address) VALUES ('".$_POST["txtUsername"]."',
'".$_POST["txtPassword"]."','".$_POST["txtName"]."' ,'".$_POST["txtEmail"]."','USER','".session_id()."','No','".$_POST["txtTel"]."','".$_POST["txtAddress"]."')";
$objQuery = mysql_query($strSQL);
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-01-22 14:34:10 |
By :
waffle |
View :
820 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณคับ ทดลอง test !!!
|
|
|
|
|
Date :
2013-01-22 16:05:18 |
By :
waffle |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|