|
 |
|
รบกวนถามเรื่อง เกี่ยวกับระบบสมัครสมาชิกค่าที่ส่งมาจากฟอร์มมันไม่มาที่หน้าบบันทึก ผู้รู้ช่วยตอบหน่อยครับ |
|
 |
|
|
 |
 |
|
คือว่าสามารถเชื่อมต่อและอัพได้ แต่ค่าที่ลงไปในดาต้าเบสเป็นค่าป่าวๆๆ
ตัวอย่างโค้ดครับ
ในส่วนฟอร์มครับ
Code (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>
<?php
include_once"connectmem.php";
?>
<style type="text/css">
<!--
#form1 {
color: #F00;
}
.a {
color: #F00;
}
.a {
color: #F00;
}
.a {
color: #F00;
}
.a {
font-family: Arial, Helvetica, sans-serif;
}
.n {
color: #0B7300;
}
.n {
font-weight: bold;
}
.m {
font-weight: normal;
}
.m {
color: #0B7300;
}
a:link {
text-decoration: none;
color: #FFF;
}
a:visited {
text-decoration: none;
color: #F90;
}
a:hover {
text-decoration: none;
color: #FFF;
}
a:active {
text-decoration: none;
color: #0B7300;
}
-->
</style>
</head>
<body text="#FFFFFF" link="#FF9933" vlink="#FFFFFF" alink="#0B7300">
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#FFFFFF">::</td>
</tr>
<tr>
<td width="76"> </td>
<td width="424"> </td>
</tr>
<tr>
<td colspan="2"><img src="image/memhead.jpg" width="500" height="40" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> ชื่อ-สกุล</td>
<td bgcolor="#CCCCCC"> <form id="form1" name="form1" method="POST" action="savemem.php">
<input name="txtname" type="text" id="txtname" size="30" maxlength="30" />
<span id="form1">* </span>
</form></td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> ที่อยู่</td>
<td bgcolor="#CCCCCC"><form id="form2" name="form2" method="POST" action="savemem.php">
<textarea name="address" id="address" cols="45" rows="6"></textarea>
</form></td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> ชื่อผู้ใช้</td>
<td bgcolor="#CCCCCC"><input name="usertxt" type="text" id="usertxt" size="30" maxlength="20" />
<span class="a">*</span></td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> รหัสผ่าน</td>
<td bgcolor="#CCCCCC"><form id="form3" name="form3" method="POST" action="savemem.php">
<input name="pass1" type="password" id="pass1" maxlength="8" />
<span class="a">*</span>
</form></td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> รีรหัสผ่าน</td>
<td bgcolor="#CCCCCC"><form id="form4" name="form4" method="POST" action="savemem.php">
<input name="pass2" type="password" id="pass2" maxlength="8" />
<span class="a">*</span>
</form></td>
</tr>
<tr>
<td align="left" bgcolor="#CCCCCC" class="m"> อีเมล</td>
<td bgcolor="#CCCCCC"><form id="form5" name="form5" method="POST" action="savemem.php">
<input name="mail" type="text" id="mail" size="30" maxlength="20" />
</form></td>
</tr>
<tr>
<td bgcolor="#CCCCCC" class="m"> เพศ</td>
<td bgcolor="#CCCCCC"><form id="form6" name="form6" method="GET" action="savemem.php">
<input name="radio" type="radio" id="radio" value="radio" checked="checked" />
ชาย
<input name="radio2" type="radio" id="radio2" value="radio2" />
หญิง
</form></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"><form id="form7" name="form7" method="POST" action="savemem.php">
<input type="submit" name="button1" id="button1" value="Submit" />
<input type="reset" name="button2" id="button2" value="Reset" />
</form></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#CCCCCC"> </td>
</tr>
<tr>
<td bgcolor="#009900"> </td>
<td bgcolor="#009900"><a href="jumlonghome.php">::HOME::</a></td>
</tr>
</table>
</body>
</html>
ในส่วนหน้าบันทึกครับ ชื่อไฟล์
Code (PHP)
<meta charset ="UTF-8">
<?php
include_once"connectmem.php";
$name = $_POST['txtname'];
$address = $_POST['address'];
$user = $_POST['usertxt'];
$pass = $_POST['pass1'];
//$pass2 = $_POST['pass2'];
$mailto = $_POST['mail'];
//$sex1 = $_GET['radio'];
//$sex2 = $_GET['radio2'];
$mysql = "INSERT INTO member(mem_name,mem_address,mem_user,mem_pass,mem_email)VALUES('$name','$address','$user','$pass','$mailto')";
$cc = mysql_query($mysql);
if($cc){
echo "บันทึกข้อมูลเรียบร้อย";
//echo "hello".$name; ตรงนี้ทดลองปริ้นค่าที่ส่งมาขึ้นแค่คำว่า hello
}
else{
echo mysql_error();
}
?>
ผู้รู้ช่วยตอบด้วยครับ ขอบคุณครับ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2013-02-25 21:46:35 |
By :
เทส |
View :
638 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมคิดว่า ตรงฟอร์มรับค่า ควรจะมีแค่ ค่าเดียวนะครับ คุณแบ่งฟอร์มหลายๆ ฟอร์ม เวลากดคลิกส่งบรรทัดที่ 136 มันก็จะไม่มีค่าส่งมาครับ
ลองทำแบบนี้นะ
Code (PHP)
<form id="form1" name="form1" method="POST" action="savemem.php">
<label>ชื่อ-สกุล</label>
<input name="txtname" type="text" class="my_date" size="10" />
<label>ที่อยู่</label>
<input name="address" type="text" class="my_date" size="10" />
<label>ชื่อผู้ใช้</label>
<input type="text" name"usertxt" >
<input type="submit" name="Search" value="Search" />
</form>
ลองตามนี้ดูครับ ฟอร์มส่งค่า น่าจะมีแค่ฟอร์มเดียวครับ ลองดูครับ 
|
 |
 |
 |
 |
Date :
2013-02-28 18:19:51 |
By :
theyounggun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|