|
|
|
ทำให้หน้าที่บันทึกข้อมูลลงฐานข้อมูล แสดงแบบ alert โดยไม่เปลี่ยนหน้า และสามารถลิงค์ไปหน้าแสดงข้อมูลแบบเป็นตารางได้ |
|
|
|
|
|
|
|
SaveForm.php
Code (PHP)
<?php
$strFirstName = $_POST["txtFirstName"];
$strLastName = $_POST["txtLastName"];
echo "<script language=\"JavaScript\">";
echo "alert('Sawatdee : $strFirstName $strLastName');";
echo "location='list.php' ";
echo "</script>";
?>
|
ประวัติการแก้ไข 2017-02-20 13:09:20
|
|
|
|
Date :
2017-02-20 13:07:36 |
By :
JJAAYY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้อ่ะครับ
Code (PHP)
<?php
$re_name=$_POST['re_name'];
$ip=$_POST['ip'];
$com_name=$_POST['com_name'];
$mac=$_POST['mac'];
$start=$_POST['start'];
$finished=$_POST['finished'];
$remark=$_POST['remark'];
mysql_connect("localhost","root","1234");
mysql_select_db("bic");
mysql_query("SET NAMES UTF8");
$sql="INSERT INTO reguester_ip(re_name,ip,com_name,mac,start,finished,remark)
VALUES('$re_name','$ip','$com_name','$mac','$start','$finished','$remark')";
$rc=mysql_query($sql);
if($rc=="1"){
echo "<script language=\"JavaScript\">";
echo "alert('บันทึกข้อมูลเรียบร้อยแล้ว');";
echo "location='list.php'";
echo "</script>";
}else{
echo "<script language=\"JavaScript\">";
echo "alert('ไม่สามารถบันทึกข้อมูลได้');";
echo "location='list.php'";
echo "</script>";
}
|
ประวัติการแก้ไข 2017-02-20 13:17:07
|
|
|
|
Date :
2017-02-20 13:15:40 |
By :
puruther |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอดูโค้ดทั้งหมดได้ป่าวครับ
|
|
|
|
|
Date :
2017-02-20 13:24:00 |
By :
JJAAYY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from.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>
<script src="file:///C|/xampp/htdocs/bic/SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="file:///C|/xampp/htdocs/bic/SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Select a Date Range</title>
<link rel="stylesheet" href="../jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.css">
<script src="../jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/external/jquery/jquery.js"></script>
<script src="../jquery-ui-1.12.1.custom/jquery-ui-1.12.1.custom/jquery-ui.js"></script>
<script>
$( function() {
var dateFormat = "yy-mm-dd",
from = $( "#start" )
.datepicker({
defaultDate: "+1w",
changeMonth: true,
dateFormat : 'yy-mm-dd',
numberOfMonths: 1
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
}),
to = $( "#finished" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
dateFormat : 'yy-mm-dd',
numberOfMonths: 1
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dateFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
} );
</script>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax() {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'check.php';
var pmeters = "ip=" + encodeURI( document.getElementById("ip").value);
HttPRequest.open('POST',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "..";
}
if(HttPRequest.readyState == 4) // Return Request
{
if(HttPRequest.responseText == 'Y')
{
window.location = 'check.php';
}
else
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
}
</script>
<body>
<p> </p>
<h2 style="text-align: center"><strong>ฟอร์มยื่นคำร้องขอ IP Address</strong></h2>
<form id="form2" name="form2" method="post" action="add.php"target="iframe_target">
<iframe id="iframe_target" name="iframe_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
<table width="500" border="0" align="center">
<tr>
<td width="184" height="38">Reguester name</td>
<td width="14" align="center">:</td>
<td width="319"><label for="re_name"></label>
<input type="text" name="re_name" id="re_name" /></td>
</tr>
<tr>
<td height="38">IP Address</td>
<td align="center">:</td>
<td><label for="textfield"></label>
<label for="ip"></label>
<span id="sprytextfield1">
<input type="text" name="ip" id="ip" OnChange="JavaScript:doCallAjax();"/>
<span id="mySpan"></span></span></td>
</tr>
<tr>
<td height="40">Computer name</td>
<td align="center">:</td>
<td><label for="com_name"></label>
<input type="text" name="com_name" id="com_name" /></td>
</tr>
<tr>
<td height="39">Mac address</td>
<td align="center">:</td>
<td><label for="mac"></label>
<input type="text" name="mac" id="mac" /></td>
</tr>
<tr>
<td height="35">From</td>
<td align="center">:</td>
<td><label for="textfield5"></label>
<input type="text" name="start" id="start" /></td>
</tr>
<tr>
<td height="40">To</td>
<td align="center">:</td>
<td><label for="textfield6"></label>
<input type="text" name="finished" id="finished" /></td>
</tr>
<tr>
<td>Remark</td>
<td align="center">:</td>
<td><label for="remark"></label>
<label for="remark"></label>
<textarea name="remark" id="remark" cols="45" rows="5"></textarea></td>
</tr>
</table>
<p align="center">
<input type="submit" name="button" id="button" value="บันทึก" />
<input type="reset" name="button2" id="button2" value="ยกเลิก" />
</p>
</form>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
</script>
</body>
</html>
add.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>
<p>
<?php
$re_name=$_POST['re_name'];
$ip=$_POST['ip'];
$com_name=$_POST['com_name'];
$mac=$_POST['mac'];
$start=$_POST['start'];
$finished=$_POST['finished'];
$remark=$_POST['remark'];
mysql_connect("localhost","root","1234");
mysql_select_db("bic");
mysql_query("SET NAMES UTF8");
$sql = "SELECT * FROM reguester_ip WHERE ip = '".$_POST["ip"]."' ";
$rc = mysql_query($sql);
if (!filter_var($ip, FILTER_VALIDATE_IP) === true) {
echo "<script language=\"JavaScript\">";
echo "alert('$ip is not a valid IP address');";
echo "window.history.go(-1);</script>";
exit;
}
$sql = "SELECT * FROM reguester_ip WHERE ip = '".$_POST["ip"]."' ";
$rc = mysql_query($sql);
$objResult = mysql_fetch_array($rc);
if($objResult)
{
echo "<script language=\"JavaScript\">";
echo "alert('IP Address นี้มีอยู่แล้ว ไม่สามารถบันทึกข้อมูลได้.');";
echo "window.history.go(-1);</script>";
exit;
}
else
{
$sql="INSERT INTO reguester_ip(re_name,ip,com_name,mac,start,finished,remark)
VALUES('$re_name','$ip','$com_name','$mac','$start','$finished','$remark')";
$rc=mysql_query($sql);
if($rc=="1"){
echo "<script language=\"JavaScript\">";
echo "alert('บันทึกข้อมูลเรียบร้อยแล้ว');";
echo "location='list.php'";
echo "</script>";
}else{
echo "<script language=\"JavaScript\">";
echo "alert('ไม่สามารถบันทึกข้อมูลได้');";
echo "location='list.php'";
echo "</script>";
}
}
mysql_close();
?>
</p>
<p align="center"><a href="list.php">ดูข้อมูลการยื่นคำขอ IP</a></p>
</body>
</html>
list.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>
<p><a href="from.php">เพิ่มข้อมูลการยื่นคำร้องขอ IP</a></p>
<p><a href="list_save.php">SAVE</a></p>
<h2 align="center">แสดงข้อมูลการยื่นคำร้องขอ IP</h2>
<form id="form1" name="form1" method="post" action="">
<p style="text-align: center"><span style="font-weight: bold">ค้นหาข้อมูลจาก</span>
<label for="s"></label>
<select name="s" id="s">
<option>192.168.100</option>
<option>192.168.101</option>
<option>192.168.102</option>
<option>192.168.103</option>
<option>192.168.104</option>
<option>192.168.105</option>
<option>192.168.106</option>
<option>192.168.107</option>
<option>192.168.108</option>
<option>192.168.109</option>
</select>
<input type="submit" name="button" id="button" value="ค้นหา" />
</p>
</Form>
</p>
<form id="form1" name="form1" method="post" action="">
<div align="center">
<div align="center">
<table width="1012" border="1">
<tr>
<td width="168" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">Reguester name</td>
<td width="135" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">IP Address</td>
<td width="148" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">Computer name</td>
<td width="125" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">Mac address</td>
<td width="85" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">From</td>
<td width="86" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">To</td>
<td width="139" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">Remark</td>
<td width="74" align="center" bgcolor="#FF0000" style="color: #FFF; font-weight: bold;">Edit</td>
</tr>
<?php
@$s=$_POST[s];
$con = mysql_connect("localhost","root","1234");
mysql_select_db("bic",$con);
mysql_query("SET NAMES UTF8");
$sql = "select * from reguester_ip where ip LIKE '%$s%' order by ip ASC "; // DESC//
$rs = mysql_query($sql,$con);
while($cols = mysql_fetch_row($rs)){
echo "<tr>
<td><center>$cols[1]</center></td>
<td><center>$cols[2]</center></td>
<td><center>$cols[3]</center></td>
<td><center>$cols[4]</center></td>
<td><center>$cols[5]</center></td>
<td><center>$cols[6]</center></td>
<td><center>$cols[7]</center></td>
<td><center><a href='edit.php?id=$cols[0]'><แก้ไข></a></center></td>
</tr>
";
}
mysql_free_result($rs);
mysql_close($con);
?>
</table>
</div>
</form>
<p align="center"> </p>
</body>
</html>
|
|
|
|
|
Date :
2017-02-20 13:30:43 |
By :
puruther |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
form.php
Code (PHP)
<form id="form2" name="form2" method="post" action="add.php" target="iframe_target">
แก้เป็น ลองดูครับ
Code (PHP)
<form id="form2" name="form2" method="post" action="add.php">
|
|
|
|
|
Date :
2017-02-20 13:59:55 |
By :
JJAAYY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ถ้าแก้ตรงนั้นมันลิงค์ได้ครับ แต่ว่ามันจะแสดง กล่องข้อความไปอยู่อีกหน้านึง คือผมอยากให้มันอยู่ในหน้า from.php อ่ะครับ
ไม่อยากให้มันไปแสดงที่ลิงค์ add.php ครับ มันพอจะทำได้หรือป่าวครับ
|
|
|
|
|
Date :
2017-02-20 14:04:33 |
By :
puruther |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|