|
 |
|
การตรวจเช็ค ip เครือ่งลงฐานข้อมูล ผมเขียนโปรแกรมจัดเก็บข้อมูลขึ้นมาตัวหนึ่งแล้วให้มันสามารถตรวจสอบ ip address |
|
 |
|
|
 |
 |
|
ผมเขียนโปรแกรมจัดเก็บข้อมูลขึ้นมาตัวหนึ่งแล้วให้มันสามารถตรวจสอบ ip address ได้ คือเวลาผมทดลองรันดู โปรแกรมมันก็แสดงนะครับ แต่เวลาบันทึกลงฐานข้อมูลปรากฏว่ามันไม่ยอมบันทึกลงไป ไม่ทราบว่าเพราะอะไร อยากให้อาจารย์แนะนำด้วยนะครับ
|||||||::::::::::::::::database::::::::::|||||||||||||
CREATE TABLE `user` (
`id` int( 5 ) NOT NULL AUTO_INCREMENT ,
`name` varchar( 30 ) NOT NULL default '',
`email` varchar( 30 ) NOT NULL default '',
`username` varchar( 20 ) NOT NULL default '',
`password` varchar( 20 ) NOT NULL default '',
`date` varchar( 25 ) NOT NULL default '',
`status` varchar( 10 ) NOT NULL default '',
PRIMARY KEY ( `id` )
) TYPE = MYISAM AUTO_INCREMENT =1
|||||||||||||||||||||||||::::form_register.php:::::|||||||||||||||
<html>
<head>
<title>สมัครสมาชิก</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"></head>
<body>
<h2 align="center">สมัครสมาชิก</h2>
<form action="confirm_register.php" method="post" name="confirm_register" id="confirm_register" >
<table align="center">
<tr>
<td>สถานพยาบาล</td><td><input name="hospital" type="text" id="hospital"></td></tr>
<tr>
<td>ชื่อ-สกุล</td><td><input name="name" type="text" id="name"></td></tr>
<tr>
<td>เลขที่บัตร</td><td><input name="identity" type="text" id="identity"></td></tr>
<tr>
<td>ที่อยู่</td><td><input name="addcard" type="text" id="addcard"></td></tr>
<tr>
<td>โทรศัพท์</td>
<td><input name="tel" type="text" id="tel"></td>
</tr>
<tr>
<td>สถานะ</td>
<td><input name="status" type="radio" value="Admit">
Admit
<input name="status" type="radio" value="Discharge">
Discharge</td>
</tr>
<tr>
<td>ip address </td><td><input name="ip" type="text" disabled id="ip" value="<?php
if (getenv(HTTP_X_FORWARDED_FOR))
$ip=getenv(HTTP_X_FORWARDED_FOR);
else
$ip=getenv(REMOTE_ADDR);
print "IP $ip";
?> ">
</td>
</tr>
<tr><td colspan="2" align="center"><input type="submit" value="สมัครสมาชิก"> <input type="reset" value="ลบใหม่ทั้งหมด"></td></tr>
</table>
</form>
<center>
</center>
<h4 align="center">* กรุณากรอกข้อมูลให้ครบ</h4>
</body>
</html>
|||||||||||||||||||||||||||||::::::::::confirm_register.php::::::::||||||||||||||||||
<?php
include("config.inc.php"); //ดึงไฟล์ config ของค่าติดต่อฐานข้อมูลและฟังก์ชั่นมาใช้งานร่วมด้วย
if($hospital=="" || $name =="" ||$identity=="" || $addcard =="" || $tel =="" || $status =="" ){ //ตรวจสอบค่าที่รับมาจากฟอร์มว่าห้ามมีค่าว่างเปล่าส่งมา
echo "<table width=550 align=center>";
echo "<tr> <td align=center bgcolor=#EAECEA><br><b>กรุณากรอกข้อมูลให้ครบ</b><br>";
echo "<a href=javascript:history.back(); >กลับไปแก้ไข</a><br><br>";
echo "</td></tr>";
echo "</table>";
} else { //เมื่อข้อมูลทั้งหมดถูกต้อง ทำการเพิ่มข้อมูลลงฐานข้อมูล
$date_register=date('l F d, Y'); //วันเดือนปีที่สมัคร รูปแบบ Thursday April 07, 2005
$SQL_insert_member="insert into $tbluser (hospital, name, identity, addcard, tel, date, status,ip) values ('$hospital', '$name', '$identity', '$addcard', '$tel', '$date_register', '$status', '$ip')";
mysql_db_query($db,$SQL_insert_member);
echo"<table width=550 align=center>";
echo"<tr> <td align=center bgcolor=#EAECEA><b>เพิ่มข้อมูลของคุณ <font color=red>$name</font> เรียบร้อยแล้วครับ</a></td></tr>";
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo"</td></tr>";
echo"<tr> <td align=center bgcolor=#EAECEA><a href=javascript:window.close();>ปิดหน้านี้</a></td></tr>";
echo"</table>";
mysql_close();
}
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
21 มิ.ย. 2549 15:40:32 |
By :
วา |
View :
3323 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ในส่วนของ---------------------------------
<td>ip address </td><td><input name="ip" type="text" disabled id="ip" value="<?php
if (getenv(HTTP_X_FORWARDED_FOR))
$ip=getenv(HTTP_X_FORWARDED_FOR);
else
$ip=getenv(REMOTE_ADDR);
print "IP $ip"; ?> ">
ผมว่านะ-------------------------
<?php
if (getenv(HTTP_X_FORWARDED_FOR))
$ip=getenv(HTTP_X_FORWARDED_FOR);
else
$ip=getenv(REMOTE_ADDR);
?>
<input name="ip" type="text" disabled id="ip" value="<?=$ip ?>">
แบบนี้น่าจะลงแล้วล่ะ ลองดูครับ
|
 |
 |
 |
 |
Date :
27 มิ.ย. 2549 11:56:10 |
By :
รู้น้อยแต่อยากช่วย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้อีกนิด ตรง input
<input name="ip" type="hidden" id="ip" value="<?=$ip ?>">
|
 |
 |
 |
 |
Date :
27 มิ.ย. 2549 11:57:28 |
By :
รู้น้อยแต่อยากช่วย |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|