|
|
|
มีปัญหาเกี่ยวกับระบบ login ค่ะ คือสามารถ login เข้า chrome และ firefox ได้ปกติ แต่ IE ไม่สามารถ login ได้เปนเพราะอะไรค่ะ รบกวนช่วยดูโค้ดให้หน่อย |
|
|
|
|
|
|
|
]มีปัญหาเกี่ยวกับระบบ login ค่ะ คือสามารถ login เข้า chrome และ firefox ได้ปกติ แต่ IE ไม่สามารถ login ได้เปนเพราะอะไรค่ะ
member.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
function member(){
var userObj, passObj, confirmObj, mailObj, nameObj, sexObj, addressObj, phoneObj, fmObj;
userObj = document.getElementById("user");
passObj = document.getElementById("pass");
confirmObj = document.getElementById("re_pass");
mailObj = document.getElementById("email");
nameObj = document.getElementById("name");
sexObj = document.getElementById("sex");
addressObj = document.getElementById("address");
phoneObj = document.getElementById("phone");
fmObj = document.getElementById("checkForm");
if(userObj.value==""){
alert("กรุณากรอก username ด้วยค่ะ");
userObj.focus();
}else if(passObj.value==""){
alert("กรุณากรอก Password ที่ต้องการด้วยค่ะ");
passObj.focus();
}else if(passObj.value.length>10) {
alert("กรุณากรอก Password น้อยกว่า 10 ตัวด้วยค่ะ");
passObj.focus();
}else if(confirmObj.value==""){
alert("กรุณายืนยันรหัสผ่านอีกครั้ง");
confirmObj.focus();
}else if(mailObj.value==""){
alert("กรุณากรอก E-mail ของท่านด้วยค่ะ");
mailObj.focus();
}else if(confirmObj.value!= passObj.value){
alert("รหัสผ่านไม่่ตรงกัน กรุณายืนยันรหัสผ่านให้ถูกต้องด้วยค่ะ");
confirmObj.focus();
}else{
fmObj.submit();
}
}
</script>
</head>
<body>
<div style="width:700px; height:auto; margin-left:30px; float:left;">
<div style="width:600px; height:30px; background-color: #bfde66; font-family:Tahoma; font-size:14px; margin-top:20px; padding-top:5px; padding-left:50px;"><img src="images/msn-icon.png" width="25" height="25"> <b>ข้อมูลสมาชิก</b></div>
<form name ="checkForm" id="checkForm" method="post" action="index.php?page=reg-chk" >
<table width="538" border="0">
<tr>
<td width="162" height="40" valign="bottom" align="right" style="font-family:Tahoma; font-size:14px; padding-bottom:8px;">User name :</td>
<td width="180" height="40" valign="bottom"> <input type="text" name="user" id="user" class="box" style="width:150px;"/></td>
<td width="182" height="40" valign="bottom" style="color:#F00; font-family:Tahoma; font-size:13px; padding-bottom:8px;"><b>*</b></td>
</tr>
<tr>
<td width="162" align="right" style="font-family:Tahoma; font-size:14px;">Password :</td>
<td> <input type="password" name="pass" id="pass" class="box" style="width:150px;"/></td>
<td width="182" style="color:#F00;"><b>*</b></td>
</tr>
<tr>
<td width="162" align="right" style="font-family:Tahoma; font-size:14px;">Re-password :</td>
<td> <input type="password" name="re_pass" id="re_pass" class="box" style="width:150px;"/></td>
<td width="182" style="color:#F00;"><b>*</b></td>
</tr>
<tr>
<td width="162" align="right" style="font-family:Tahoma; font-size:14px;">E-mail :</td>
<td> <input type="text" name="email" id="email" class="box" style="width:150px;"/></td>
<td width="182" style="color:#F00;"><b>*</b></td>
</tr>
</table>
<div style="width:600px; height:30px; background-color: #bfde66; font-family:Tahoma; font-size:14px; margin-top:30px; padding-top:5px; padding-left:50px;"><img src="images/msn-icon.png" width="25" height="25"> <b>ข้อมูลส่วนตัว</b></div>
<table width="539" border="0">
<tr>
<td width="170"height="40" valign="bottom" align="right" style="font-family:Tahoma; font-size:14px; padding-bottom:8px;">ชื่อ - นามสกุล :</td>
<td width="368"height="40" valign="bottom"> <input type="text" name="name" id="name" class="box" style="width:150px;"/></td>
</tr>
<tr>
<td width="170" align="right" style="font-family:Tahoma; font-size:14px;">เพศ :</td>
<td> <input name="sex" type="radio" value="male"><span style="font-family:Tahoma; font-size:14px;"> ชาย</span> <input name="sex" type="radio" value="female"><span style="font-family:Tahoma; font-size:14px;">หญิง</span></td>
</tr>
</tr>
<tr>
<td width="170" align="right" style="font-family:Tahoma; font-size:14px;">ทีอยู่ :</td>
<td> <textarea name="address" cols="30" rows="4"> </textarea></td>
</tr>
<tr>
<td width="170" align="right" style="font-family:Tahoma; font-size:14px;">เบอร์โทรศัพท์ :</td>
<td> <input type="text" name="phone" id="phone" class="box" style="width:150px;"/></td>
</tr>
<tr>
<td width="170" height="60" align="right"><input name="save" type="button" value="Save" style="height:25px; width:60px; font-family:Tahoma; font-size:14px;" onClick="member();"></td>
<td height="60"><span style="padding-left:10px;"><input name="clear" type="reset" value="Clear" style="height:25px; width:60px; font-family:Tahoma; font-size:14px;"></span></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
reg_chk.php
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$username=$_POST['user'];
$password=$_POST['pass'];
$repassword=$_POST['re_pass'];
$email=$_POST['email'];
$name=$_POST['name'];
$sex=$_POST['sex'];
$address=$_POST['address'];
$telephone=$_POST['phone'];
require_once('config.inc.php');
mysql_query("INSERT INTO member (m_id, username, password, email, name, sex, address, telephone) VALUES ('null','$_POST[user]','$_POST[pass]','$_POST[email]','$_POST[name]','$_POST[sex]','$_POST[address]','$_POST[phone]')") or die(mysql_error());
// บันทึกข้อมูลลงฐานข้อมูล
mysql_connect($dbhost,$dbuname,$dbpass);
mysql_query("SET NAMES UTF8");
/*$sql = "INSERT INTO tbl_member(id,user,pwd,name,sex,address,province,code,mail)VALUES(null,'$user','$pwd','$name','$sex','$province','$mail')";*/
//echo $sql;
$result = mysql_db_query($dbname,$sql);
echo "<script> alert('สมัครสมาชิกเรียบร้อยแล้วค่ะ');</script>";
echo "<script langquage='javascript'>";
echo "window.location='index.php?page=home';";
echo "</script>";
mysql_close();
?>
<!--สำหรับสั่งให้ refresh หน้าเว็บเพจที่แสดงผลอยู่อัตโนมัติ-->
<META HTTP-EQUIV="refresh" CONTENT="0;URL=index.php?page=home">
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-12-21 13:55:48 |
By :
nubum |
View :
976 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
require_once('config.inc.php');
$dbhost = 'localhost';
$dbuname = 'root';
$dbpass = '';
mysql_connect($dbhost,$dbuname,$dbpass);
mysql_query("SET NAMES UTF8");
$username=$_POST['user'];
$password=$_POST['pass'];
$repassword=$_POST['re_pass'];
$email=$_POST['email'];
$name=$_POST['name'];
$sex=$_POST['sex'];
$address=$_POST['address'];
$telephone=$_POST['phone'];
$sql = " INSERT INTO member (m_id, username, password, email, name, sex, address, telephone) ";
$sql.= " VALUES ";
$sql.= " '".$username."','".$passowrd."','".$repassword."','".$email."', '".$name."', '".$sex."','".$address."','".$telephone."') ";
$qr = mysql_query($sql) or die(mysql_error());
if($qr){
echo "<meta http-equiv=\"Refresh\" content=\"0; URL=index.php?page=home\">";
}else{
//do something...
}
mysql_close();
?>
เท่าที่ดู คุณลืมฟิลด์ name หรือเปล่าลองแบบ นี้ดูนะแล้วก็อีกอย่างนะครับผมแนะนำ สร้างตัวแปรมารับค่าแล้วค่อยนำไปใช้น่าจะดีกว่านะครับ
|
|
|
|
|
Date :
2012-12-21 15:22:00 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
//*** database connection config ***//
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = '';
$dbConn = mysql_connect ($dbHost, $dbUser, $dbPass) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($dbName) or die('Cannot select database. ' . mysql_error());
mysql_query("SET NAMES UTF8");
?>
สร้างไฟล์ connect_db.php มาไว้ก็ดีเหมือนกันนะครับ เวลาจะติดต่อฐานข้อมูลก็เรียกใช้ไฟล์นี้ได้เลยไม่ต้องมาเขียนติดต่อฐานข้อมูลทุกไฟล์
|
|
|
|
|
Date :
2012-12-21 15:24:22 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณค่ะ
|
|
|
|
|
Date :
2012-12-21 15:40:59 |
By :
nubum |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[email protected] ปรึกษา PHP+MySQL+AJAX+Javascript+Jquery+CSS ฟรีจร้า
|
|
|
|
|
Date :
2012-12-21 15:45:49 |
By :
popnakub |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|