 |
login แล้วไม่สามารถลิ้งค์ไปหน้าที่ต้องการได้ครับ มันไปหน้าอะไรไม่รู้ |
|
 |
|
|
 |
 |
|
ไฟล์ที่ 2 ครับ ตรวจสอบแล้วส่งไปฐานข้อมูล
Code (PHP)
<?
session_start();
$host = "localhost";
$user = "bookwo2";
$passwd = "i3oCxY";
$dbname = "bookwo2_book";
$logname=$_POST['logname'];
$pw=$_POST['pw'];
mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
$sql = "select * from admin where useradmin='$logname' and pwadmin='$pw' ";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($check == "on")
{
setcookie("logname",$logname,time()+3600*24*356);
setcookie("pw",$pw,time()+3600*24*356);
header("location:data.html");
} else {
header("location:data.html");
}
}else {
$code_error="<span class=style2> ข้อมูลไม่ถูกต้องกรุณา Login ใหม่</span> ";
session_register("code_error");
header("location:formlogin.php");
};
?>
|
 |
 |
 |
 |
Date :
2011-09-15 21:45:04 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มี error แจ้งหรือเปล่าครับ 
|
 |
 |
 |
 |
Date :
2011-09-15 22:06:13 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เลยครับ มันลิ้งค์ไปหน้าอะไรไม่รู้อ่ะครับ
นี่คือลิ้งค์ที่มันไปครับ
http://www.bookworm.vpsq.net/
|
 |
 |
 |
 |
Date :
2011-09-15 22:08:47 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?
session_start();
$host = "localhost";
$user = "bookwo2";
$passwd = "i3oCxY";
$dbname = "bookwo2_book";
$logname=$_POST['logname'];
$pw=$_POST['pw'];
mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
$sql = "select * from admin where useradmin='$logname' and pwadmin='$pw' ";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($check == "on")
{
setcookie("logname",$logname,time()+3600*24*356);
setcookie("pw",$pw,time()+3600*24*356);
echo "<script>alert('ยินดีต้อนรับ');window.location='data.html'</script>";
} else {
header("location:data.html");
}
}else {
//$code_error="<span class=style2> ข้อมูลไม่ถูกต้องกรุณา Login ใหม่</span> ";
session_register("code_error");
echo "<script>alert('ล็อกอินไม่ได้');window.location='ormlogin.php'</script>";
};
?>
ลองเอาไปใช้ครับ ถ้ามันไม่ขึ้นอันเลิส แสดงว่าคุณ action ไฟล์ผิดครับ แต่ถ้าขึ้นแล้วมันยังไปหน้าที่คุณบอกอีกเอาโค้ดทั้งหมดมาดูพร้อมชื่อไฟล์
|
 |
 |
 |
 |
Date :
2011-09-16 00:48:09 |
By :
gmgo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ผิดมันน่าจะอยู่ในไฟล์
data.html
ลองเอามาลงดูให้หน่อยนะ
|
 |
 |
 |
 |
Date :
2011-09-16 09:15:17 |
By :
nimporn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ครับผม ก่อนอื่นต้องขอขอบคุณพวกพี่ๆมากๆครับ
ไฟล์แรก ไฟล์ Formregister.php
เป็นไฟล์หน้า login
<!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=windows-874" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-size: 36px;
color: #000066;
}
.style2 {
color: #FF33CC;
font-weight: bold;
}
-->
</style>
</head>
<body>
<?php
print"วันที่".date(" D d F Y เวลา h:i:s A");
?>
<table width="1034" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td height="136" colspan="2" valign="top" bgcolor="#FFCCCC"><img src="imagesWeb/06.jpg" width="1037" height="225" /></td>
</tr>
<tr>
<td width="297" rowspan="2" valign="top" bgcolor="#33FF00"><img src="imagesWeb/1139804534.jpg" width="300" height="903" /></td>
<td width="737" height="493" valign="top"><form id="formregis" name="formregis" method="post" action="AddData.php">
<p align="right"> </p>
<p align="center" class="style1 style2">ข้อมูลการสมัครสมาชิก</p>
<center>
<table width="729" border="0" bgcolor="#FFFFFF">
<tr>
<td width="105" height="56" bordercolor="#FF00FF" class="style2">ชื่อล็อกอิน</td>
<td width="218" class="style2"><input name="logname" type="text" id="logname" size="20" maxlength="15" /></td>
<td width="150" class="style2">เพศ</td>
<td width="238" class="style2"><p>
<label>
<input type="radio" name="gender" value="male" />
ชาย</label>
<label>
<input type="radio" name="gender" value="female" />
หญิง</label>
<br />
</p></td>
</tr>
<tr>
<td height="46" bordercolor="#FF00FF" class="style2">รหัสผ่าน</td>
<td class="style2"><input name="psswd" type="password" id="psswd" size="20" maxlength="15" /></td>
<td class="style2">อายุ</td>
<td class="style2"><select name="age" id="age">
<option value="3-18" selected="selected">3-18ปี</option>
<option value="19-25">19-25ปี</option>
<option value="26-45">26-45ปี</option>
<option value="46-60">46-60ปี</option>
<option value="61-80">61-80ปี</option>
</select> </td>
</tr>
<tr>
<td height="43" bordercolor="#FF00FF" class="style2">ชื่อ-นามสกุล</td>
<td class="style2"><input name="name" type="text" id="name" size="30" maxlength="25" /></td>
<td class="style2">งานอดิเรก</td>
<td class="style2"> <input name="hobby1" type="checkbox" id="hobby1" value="sport" />
เล่นกีฬา <br />
<input name="hobby2" type="checkbox" id="hobby2" value="reading" />
อ่านหนังสือ <br />
<input name="hobby3" type="checkbox" id="hobby3" value="tour" />
ท่องเที่ยว <br />
<input name="hobby4" type="checkbox" id="hobby4" value="game" />
เกมส์</td>
</tr>
<tr>
<td height="86" bordercolor="#FF00FF" class="style2">ที่อยู่</td>
<td class="style2"><textarea name="address" cols="30" rows="5" id="address"></textarea></td>
<td class="style2">รู้จักเว็บไซต์นี้จากแหล่งใด</td>
<td class="style2"><select name="know" id="know">
<option value="newspaper" selected="selected">หนังสือพิมพ์</option>
<option value="book">หนังสือในเครือสำนักพิมพ์</option>
<option value="internet">อินเตอร์เน็ต</option>
<option value="poster">ใบปลิว</option>
</select> </td>
</tr>
<tr>
<td height="42" bordercolor="#FF00FF" class="style2">อีเมล์</td>
<td class="style2"><input name="Email" type="text" id="Email" size="30" maxlength="25" /></td>
<td class="style2">โทรศัพท์</td>
<td class="style2"><input name="Tel" type="text" id="Tel" size="25" maxlength="16" /></td>
</tr>
<tr>
<td height="33" bordercolor="#FF00FF" class="style2"> </td>
<td class="style2"><input type="submit" name="Submit" value="ส่งข้อมูล" /></td>
<td class="style2"><input name="Reset" type="reset" id="Reset" value="ล้างข้อมูล" /></td>
<td class="style2"> </td>
</tr>
</table>
</center>
</form></td>
</tr>
<tr>
<td height="29"><div align="center"><a href="index.html">HOME</a></div></td>
</tr>
</table>
<div align="right"></div>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-09-16 20:00:08 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไฟล์ที่ 2 ไฟล์ CHECKUSER.php
เป็นไฟล์นำทางไปยังลิ้งค์ที่ต้องการ หากlogin ถูกต้อง
<?
session_start();
$host = "localhost";
$user = "bookwo2";
$passwd = "i3oCxY";
$dbname = "bookwo2_book";
$logname=$_POST['logname'];
$pw=$_POST['pw'];
mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
$sql = "select * from admin where useradmin='$logname' and pwadmin='$pw' ";
$dbquery = mysql_db_query($dbname, $sql);
$num_rows = mysql_num_rows($dbquery);
if($num_rows==1)
{
if($check == "on")
{
setcookie("logname",$logname,time()+3600*24*356);
setcookie("pw",$pw,time()+3600*24*356);
echo "<script>alert('ยินดีต้อนรับ');window.location='data.html'</script>";
} else {
header("location:data.html");
}
}else {
//$code_error="<span class=style2> ข้อมูลไม่ถูกต้องกรุณา Login ใหม่</span> ";
session_register("code_error");
echo "<script>alert('ล็อกอินไม่ได้');window.location='ormlogin.php'</script>";
};
?>
|
 |
 |
 |
 |
Date :
2011-09-16 20:02:16 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไฟล์ที่ 3 data.html
อันนี้เป็นหน้าที่ login มาแล้วจะเจอ หน้า data.html คือผมไม่ได้เขียนสคริตป์หน้านี้ ผมใช้ Protoshop สร้าง แล้วก็ ดรีม ทำลิ้งค์อ่ะครับ
|
 |
 |
 |
 |
Date :
2011-09-16 20:05:43 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผิดครับขอโทษทีครับ
เอาไฟล์ผิดมาให้ดู ไฟล์ที่เอามาผิดคือ ไฟล์ Formregister.php
จริงๆมันต้องเป็น Fromlogin.php
<?
session_start();
?>
<EMBED style="LEFT: 0px; WIDTH: 820px; POSITION: absolute; TOP: 0px; HEIGHT: 370px" align=right src= http://imgfree.21cn.com/free/flash/17.swf width width=820 height=370 type=application/octet-stream wmode="transparent" quality="high" ;;></EMBED>
<EMBED style="LEFT: 0px; WIDTH: 820px; POSITION: absolute; TOP: 0px; HEIGHT: 370px" align=right src= http://imgfree.21cn.com/free/flash/38.swf width width=820 height=370 type=application/octet-stream wmode="transparent" quality="high" ;;></EMBED>
<EMBED style="LEFT: 0px; WIDTH: 820px; POSITION: absolute; TOP: 0px; HEIGHT: 370px" align=right src= http://imgfree.21cn.com/free/flash/113.swf width width=820 height=370 type=application/octet-stream wmode="transparent" quality="high" ;;></EMBED>
<EMBED style="LEFT: 0px; WIDTH: 820px; POSITION: absolute; TOP: 0px; HEIGHT: 370px" align=right src= http://imgfree.21cn.com/free/flash/130.swf width width=820 height=370 type=application/octet-stream wmode="transparent" quality="high" ;;></EMBED>
<html>
<head><title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
body {
background-image: url(imagesWeb/Mount_Fuji.jpg);
background-color: #0066CC;
}
-->
</style></head>
<body>
<p><br>
<br>
<br>
</p>
<form name="form1" method="post"action="CHECKUSER.php">
<table width="332" height="175"border="0"align="center">
<tr>
<td wicth="86"><span class"style8"><strong>Username :</strong></span></td>
<td wicth="147"><input type="text"name="logname"></td>
</tr>
<tr>
<td><span class="style8"><strong>Password:</strong></span></td>
<td><input type="password" name="pw"></td>
</tr>
<td> </td>
<td> </td>
<tr>
<td colspan="2"><div align="center"><input type="submit" name="Submit" value="Lonin"></div></td>
</tr>
</table>
<div align="center"><? print"$code_error";?></div>
</form>
</body>
</html>
|
 |
 |
 |
 |
Date :
2011-09-16 20:09:24 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมเองก็คิดว่าไฟล์ CHECKUSER.php ผิดนะครับ แต่ไม่รู้จะแก้ตรงไหน
|
 |
 |
 |
 |
Date :
2011-09-16 21:49:36 |
By :
เบียร์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|