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,028

HOME > PHP > PHP Forum > สอบถามปัญหาการเขียนโค้ดของระบบ Register / PHP / E-mail



 

สอบถามปัญหาการเขียนโค้ดของระบบ Register / PHP / E-mail

 



Topic : 118347



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



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



พอดีเขาเขียนเว็บขึ้นมาค่ะ แล้วก็มาเปิดดูโค้ดเอา เป็นมือใหม่หัดเขียน
แล้วเราก็เอาโค้ดที่ได้มาเพิ่มเนื้อหานิดหน่อย
มันก็ทำงานได้ดี ไม่มีแจ้งเตือนอะไรค่ะ แต่พอเข้าไปดูในดาต้าเบส ปรากฎดว่าข้อมูลที่กรอกไป ไม่เข้า
แก้อยู่นานเลยค่ะ ไม่เข้าใจจริง ๆ ใครพอแก้ได้ช่วบอกหน่อยนะค่ะ

ดาต้าเบส

Register.php
Code (PHP)
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>tast</title>
</head>

<body>
<p>&nbsp;</p>
<form name="form1" method="post" action="../3.php">
  <table width="646" border="0" align="center">
    <tr>
      <th width="242" align="left">&nbsp;Username</th>
      <th width="394" align="left"><label for="txtuname"></label>
      <input name="txtuname" type="text" id="txtuname" size="40"></th>
    </tr>
    <tr>
      <th align="left">&nbsp;Password</th>
      <th align="left"><input name="txtpass" type="password" id="txtpass" size="40"></th>
    </tr>
    <tr>
      <th align="left">&nbsp;Confirm Password</th>
      <th align="left"><label for="txtconfirmpass"></label>
      <input name="txtconfirmpass" type="password" id="txtconfirmpass" size="40"></th>
    </tr>
    <tr>
      <th align="left">ชื่อ</th>
      <th align="left"><label for="txtname"></label>
      <input name="txtname" type="text" id="txtname" tabindex="40" size="40"></th>
    </tr>
    <tr>
      <th align="left">นามสกุล</th>
      <th align="left"><label for="txtlast"></label>
      <input name="txtlast" type="text" id="txtlast" size="40"></th>
    </tr>
    <tr>
      <th align="left" valign="top">รหัสบัตรประชาชน</th>
      <th align="left"><label for="txtidcard"></label>
      <input name="txtidcard" type="text" id="txtidcard" size="40" maxlength="13"></th>
    </tr>
    <tr>
      <th align="left" valign="top">ที่อยู่</th>
      <th align="left"><label for="txtaddress"></label>
      <textarea name="txtaddress" cols="40" id="txtaddress"></textarea></th>
    </tr>
    <tr>
      <th align="left">เบอร์โทรศัพท์</th>
      <th align="left"><label for="txtcall"></label>
      <input name="txtcall" type="text" id="txtcall" size="40"></th>
    </tr>
    <tr>
      <th align="left">E-mail</th>
      <th align="left"><label for="txtemail"></label>
      <input name="txtemail" type="text" id="txtemail" size="40"></th>
    </tr>
    <tr>
      <th align="left">จบรุ่นที่</th>
      <th align="left"><label for="txtyear"></label>
      <input name="txtyear" type="text" id="txtyear" size="15" maxlength="4"></th>
    </tr>
    <tr>
      <th colspan="2" align="center"><input type="submit" name="save" id="save" value="สมัครสมาชิก">
      &nbsp;
      <input type="reset" name="Reset" id="button" value="ล้างข้อมูล"></th>
    </tr>
  </table>
</form>

</body>
</html>


ส่วนไฟล์ที่ทำการส่งอยู่อีกโฟเดอร์ ชื่อไฟล์ 3.php
Code (PHP)
<?php
session_start();
	mysql_connect("localhost","root","root");
	mysql_select_db("863811");
	
	if(trim($_POST["txtuname"]) == "")
	{
		echo "<script>alert('กรุณากรอกชื่อผู้ใช้ของท่าน!');</script>";
		exit();
	}

	if(trim($_POST["txtpass"]) == "")
	{
		echo "<script>alert('กรุณากรอกรหัสผ่าน!');</script>";
		exit();
	}

	if($_POST["txtpass"] != $_POST["txtconfirmpass"])
	{
		echo "<script>alert('รหัสผ่านไม้ตรงกัน กรุณากรอกใหม่!');</script>";
		exit();
	}

	if(trim($_POST["txtname"]) == "")
	{
		echo "<script>alert('กรุุณากรอกชื่อของท่าน');</script>";
		exit();
	}

	if(trim($_POST["txtlast"]) == "")
	{
		echo "<script>alert('กรุุณากรอกนามสกุลของท่าน');</script>";
		exit();
	}

	if(trim($_POST["txtidcard"]) == "")
	{
		echo "<script>alert('กรุุณากรอกเลขบัตรประจำตัวประชาชนของท่าน');</script>";
		exit();
	}

	if(trim($_POST["txtaddress"]) == "")
	{
		echo "<script>alert('กรุุณากรอกที่อยู่ของท่าน!';</script>";
		exit();
	}

	if(trim($_POST["txtcall"]) == "")
	{
		echo "<script>alert('กรุุณากรอกเบอร์โทรศัพท์ของท่าน');</script>";
		exit();
	}

	if(trim($_POST["txtemail"]) == "")
	{
		echo "<script>alert('กรุุณากรอก E-mail ของท่าน');</script>";
		exit();
	}

	if(trim($_POST["txtyear"]) == "")
	{
		echo "<script>alert('กรุุณากรอกรุ่นที่จบของท่าน');</script>";
		exit();
	}
	
	$strSQL = "SELECT * FROM mem WHERE Username = '".trim($_POST['txtuname'])."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	if($objResult)
	{
			echo "<script>alert('มีชื่อผู้ใช้นี้แล้ว กรุณากรอกซื่อผู้ใช้ใหม่');</script>";
	}
	else
	{
		mysql_connect("localhost","root","root");
		mysql_select_db("863811");
		$strSQL = "INSERT INTO mem (Username,Password,Name,LastName,IDCard,Address,Call,Email,Year,Status,Active) VALUES ('".$_POST["txtuname"]."',
		'".$_POST["txtpass"]."','".$_POST["txtname"]."' ,'".$_POST["txtlast"]."' ,'".$_POST["txtidcard"]."' ,'".$_POST["txtaddress"]."' ,'".$_POST["txtcall"]."' ,'".$_POST["txtemail"]."','".$_POST["txtyear"]."','USER','".session_id()."','No')";
		$objQuery = mysql_query($strSQL);

		$Uid = mysql_insert_id();
		echo "<script>alert('ทำการสมัครสมาชิดเรียบร้อบแล้ว!<br>กรุณาตรวจสอบ E-mail เเพื่อทำการยืนยันการสมัครสมาชิก');;window.location='index.php';</script>";

		$strTo = $_POST["txtemail"];
		$strSubject = "ขั้นตอนการยืนยันการสมัครสมาชิกสมาคมศิษย์เก่าบวรนิเวศ";
		$strHeader = "Content-type: text/html; charset=windows-874\n"; // or UTF-8 //
		$strHeader .= "From: [email protected]\nReply-To: [email protected]";
		$strMessage = "";
		$strMessage .= "ยินดีต้อนรับ : ".$_POST["txtname"]."<br>";
		$strMessage .= "=================================<br>";
		$strMessage .= "วิธีการยืนยันการสมัครสมาชิก<br>";

		$strMessage .= "=================================<br>";
		$strMessage .= "ขอบคุณ<br>";

		$flgSend = mail($strTo,$strSubject,$strMessage,$strHeader);

	}

	mysql_close();
?>



ขอความกรุณาด้วยน่ะ



Tag : PHP, MySQL









ประวัติการแก้ไข
2015-08-12 10:24:53
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-08-12 10:22:31 By : Narybee View : 1035 Reply : 5
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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

Code
$objQuery = mysql_query($strSQL) or die(mysql_error());


ดู Error หน่อยครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-12 12:46:24 By : mr.win
 


 

No. 2



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



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

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Call,Email,Year,Status,Active) VALUES ('rosir', '123','Rosirro' ,'Rosetta' ,'' at line 1 ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2015-08-12 12:46:24
รายละเอียดของการตอบ ::
ค่ะลองทำตามที่บอกปรากฎว่ามันขึ้น

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Call,Email,Year,Status,Active) VALUES ('rosir', '123','Rosirro' ,'Rosetta' ,'' at line 1


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-12 18:55:14 By : Narybee
 

 

No. 3



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



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


ดูท่าน่าจะผิดตรงคำว่า Call นะครับผม
เพราะมันเป็นคำสงวน

Go to : https://www.thaicreate.com/tutorial/sql-mysql-reserved-words.html

ลองเปลี่ยนฟิว Call เป็น Phone น่าจะ insert ลงฐานข้อมูลได้นะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-12 23:00:43 By : k.voyza
 


 

No. 4



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



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

ทำได้ แล้วววววว
ขอบคุณมากค่ะ
เป็นเพราะคำสงวน ค่ะ
ขอบคุณทุกคนมากเลยค่ะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-13 00:30:12 By : Narybee
 


 

No. 5



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

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


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-08-13 09:10:28 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามปัญหาการเขียนโค้ดของระบบ Register / PHP / E-mail
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 03
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 อัตราราคา คลิกที่นี่