|
 |
|
ทำฟอร์มสมัครสมาชิกแต่บันทึกข้อมูลลง db ไม่ได้ครับ ช่วยดูให้ทีครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
include("./config.php");
if(isset($_POST['submit']))
{
$strSQL = "INSERT INTO customers (username,password,email,status) VALUES ('".$_POST["username"]."',
'".md5($_POST["p1"])."','".$_POST["email"]."','".$_POST["ddlStatus"]."')";
$objQuery = mysql_query($strSQL) or die($strSQL);
echo "Register Complete";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>register</title>
<script language="Javascript">
function VF_form_register() {
var theForm = document.form_register;
var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
var errMsg = "";
var setfocus = "";
if (!emailRE.test(theForm['email'].value)){
errMsg = "กรุณาระบุ Email ให้ถูกต้อง";
setfocus = "['email']";
}
if (theForm['p2'].value == "" || (theForm['p2'].value != theForm['p1'].value)){
errMsg = "กรุณาระบุ password ให้ตรงกัน";
setfocus = "['p2']";
}
if (theForm['p1'].value.length < 6 || theForm['p1'].value.length > 20){
errMsg = "กรุณาระบุ password 6\-20 ตัวอักษร";
setfocus = "['p1']";
}
if (theForm['username'].value.length < 6 || theForm['username'].value.length > 20){
errMsg = "กรุณาระบุ username 6\-20 ตัวอักษร";
setfocus = "['username']";
}
if (errMsg != ""){
alert(errMsg);
eval("theForm" + setfocus + ".focus()");
}
else theForm.submit();
}
</script>
</head>
<body>
<div>
<form name="form_register" id="form_register" enctype="multipart/form-data" method="post"
action="" onsubmit="VF_form_register();return false;">
<table>
<tbody>
<tr>
<td width="125"> Username</td>
<td width="180">
<input name="username" type="text" id="username" size="20">
</td>
</tr>
<tr>
<td> Password</td>
<td><input name="p1" type="password" id="p1">
</td>
</tr>
<tr>
<td> Confirm Password</td>
<td><input name="p2" type="password" id="p2">
</td>
</tr>
<tr>
<td> email</td>
<td><input name="email" type="text" id="email" size="35"></td>
</tr>
<tr>
<td> Status</td>
<td>
<select name="ddlStatus" id="ddlStatus">
<option value="ADMIN">ADMIN</option>
<option value="USER">USER</option>
</select>
</td>
</tr>
</tbody>
</table>
<br>
<a href="javascript:VF_form_register();">สมัครสมาชิก</a>
</form>
</div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2014-06-20 14:36:24 |
By :
compiak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$_POST['submit'] คืออะไร ไม่ช่ายไม่มีตัวนี้เลย มันลอยมาจากไหน บรรทัดที่ 03 ปรับเป็น
if(isset($_POST['username']) && isset($_POST['p1']) && isset($_POST['email']) && isset($_POST['ddlStatus']) )
|
 |
 |
 |
 |
Date :
2014-06-20 15:19:10 |
By :
meannerss |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|