Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ทำให้กล่องข้อความเช็คข้อมูลซ้ำ อยู่หน้าเดียวกันกับ หน้ากรอกแบบฟอร์ม



 

ทำให้กล่องข้อความเช็คข้อมูลซ้ำ อยู่หน้าเดียวกันกับ หน้ากรอกแบบฟอร์ม

 



Topic : 126463



โพสกระทู้ ( 51 )
บทความ ( 0 )



สถานะออฟไลน์




ผมได้ทำการเช็ค user ซ้ำแล้วให้มันเช็คเป็นต่างข้อความขึ้นมา

แต่มันจะไปอยู่อีกหน้านึง ผมอยากได้วิธีให้มัน อยู่หน้าที่กรอกข้อมูล แล้วมีกล่องข้อความขึ้นมา

แทนที่จะไปแสดงอีกหน้านึง อยากจะให้มันแสดง แบบ รูปด้านล่างอ่ะครับ

Ex.

ตอนนี้มันจะไปอีกหน้านึงแบบรูปด้านล่างครับ

ww



Tag : PHP, Ms SQL Server 2012







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-02-17 16:54:14 By : puruther View : 2173 Reply : 5
 

 

No. 1

Guest


alert เสร็จแล้วก็ return false ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-17 19:11:36 By : เด็กหัวกะโป๊ก
 


 

No. 2



โพสกระทู้ ( 738 )
บทความ ( 0 )



สถานะออฟไลน์


alert('IP Address นี้มีอยู่แล้ว ไม่สามารถบันทึกข้อมูลได้.');
return false;

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-17 21:32:15 By : tomrambo
 

 

No. 3



โพสกระทู้ ( 51 )
บทความ ( 0 )



สถานะออฟไลน์


คือตอนนี้โค้ดผมเป็นแบบนี้ครับ

หน้าสำหรับกรอกข้อมูล
<!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>&nbsp;</p>
<h2 style="text-align: center"><strong>ฟอร์มยื่นคำร้องขอ IP Address</strong></h2>
<form id="form2" name="form2" method="post" action="add.php">
  <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>


หน้าสำหรับ save
<!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 "window.location='list.php'</script>";
}else{
   		echo "<script language=\"JavaScript\">";
		echo "alert('ไม่สามารถบันทึกข้อมูลได้');";
		echo "window.location='list.php'</script>";
}

}
mysql_close(); 
?>
</p>
<p align="center"><a href="list.php">ดูข้อมูลการยื่นคำขอ IP</a></p>


</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-17 22:53:27 By : puruther
 


 

No. 4



โพสกระทู้ ( 51 )
บทความ ( 0 )



สถานะออฟไลน์


ผมอยากจะให้มันเด้งขึ้นมาที่หน้า กรอกข้อมูลอ่ะครับ

ไม่ใช่หน้า add.php

คือหน้ากรอกข้อมูลผมให้มันลิงค์ไปที่หน้า add.php เมื่อกดบันทึก

หน้าต่างสำหรับเช็คมันเลยไปเป็นอีกลิงค์นึง

ผมอยากให้มันหน้าต่างเช็ค มันขึ้นอยู่ที่หน้ากรอกข้อมูลอ่ะครับ

ช่วยทีนะครับ


ประวัติการแก้ไข
2017-02-17 22:57:40
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-17 22:56:45 By : puruther
 


 

No. 5



โพสกระทู้ ( 738 )
บทความ ( 0 )



สถานะออฟไลน์


ควรจะมี 3 หน้านะครับ 1.ฟอร์ม 2.เช็ค ip ซ้ำ 3. บันทึกข้อมูล


หน้าฟอร์ม

<!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 == 1)
					{
            document.getElementById("button1").disabled = true;
            alert('IP Address นี้มีอยู่แล้ว ไม่สามารถบันทึกข้อมูลได้.');
					}
					else
					{
						document.getElementById("button1").disabled = false;
            document.getElementById("mySpan").innerHTML = '<b>&#10004;</b>';
					}
				}
				
			}

	   }
	</script>



<body>

<p>&nbsp;</p>
<h2 style="text-align: center"><strong>ฟอร์มยื่นคำร้องขอ IP Address</strong></h2>
<form id="form2" name="form2" method="post" action="add.php">
  <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="button1" 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>




check.php

<?php

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);
$num = mysql_num_rows($rc);

if($num){

echo 1;

} else {

echo 0;

}
?>






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="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){
   		echo "<script language=\"JavaScript\">";
		echo "alert('บันทึกข้อมูลเรียบร้อยแล้ว');";
		echo "window.location='list.php'</script>";
}else{
   		echo "<script language=\"JavaScript\">";
		echo "alert('ไม่สามารถบันทึกข้อมูลได้');";
		echo "window.location='list.php'</script>";
}

?>
</p>
</body>
</html>



ประวัติการแก้ไข
2017-02-17 23:44:40
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-17 23:42:03 By : tomrambo
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ทำให้กล่องข้อความเช็คข้อมูลซ้ำ อยู่หน้าเดียวกันกับ หน้ากรอกแบบฟอร์ม
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่