 |
|
Code Testinput.php Error ตรง if(isset(($_GET["login"] !== "null")) กับ if(isset(($_GET["show"] !== "null")) ช่วยแก้ปัญหา Code ให้หน่อย โดย Code PHP ทั้ง 2 ไฟล์ อยู่ข้างล่างครับ
1.FormInput.php
Code (PHP)
<form method="post" action="TestInput.php" enctype="multipart/form-data">
สมัคร ข้อมูลส่วนตัว
<table>
<tr>
<td>รหัส</td>
<td><input type="text" name="txtId"></td>
</tr>
<tr>
<td>ชื่อ</td>
<td><input type="text" name="txtName"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="text" name="txtPassword"></td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" value="102400" />
<input type="file" name="fupload" /><br/>
<input type="submit" name="register" value="Add">
<input type="submit" name="login" value="login">
<input type="submit" name="show" value="show">
</form>
2.TestInput.php
Code (PHP)
<?php
if(isset($_POST["Add"]))
print $_POST["txt"];
mysql_connect("localhost","root","123456");
mysql_select_db("tum");
$txtid = $_POST['txtId'];
$txtname = $_POST['txtName'];
$txtpassword = $_POST['txtPassword'];
$query = "INSERT INTO student(ID , Name , Password) values('$txtid','$txtname','$txtpassword')";
$result = mysql_query($query);
// Display an appropriate message
if ($result)
print "<p>Product successfully inserted!</p>";
else
print "<p>There was a problem inserting the name!</p>";
mysql_close();
if(isset(($_GET["login"] !== "null"))
{
$objConnect = mysql_connect("localhost","root","123456") or die("Error Connect to Database");
$objDB = mysql_select_db("tum");
// Search By Name or Email
$strSQL = "SELECT * FROM customer WHERE (Name LIKE '%".$_GET["txtKeyword"]."%' or Email LIKE '%".$_GET["txtKeyword"]."%' )";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?php echo $objResult["CustomerID"];?></div></td>
<td><?php echo $objResult["Name"];?></td>
<td><?php echo $objResult["Email"];?></td>
<td><div align="center"><?php echo $objResult["CountryCode"];?></div></td>
<td align="right"><?php echo $objResult["Budget"];?></td>
<td align="right"><?php echo $objResult["Used"];?></td>
</tr>
<?php
}
?>
</table>
<?php
mysql_close($objConnect);
}
if(isset(($_GET["show"] !== "null"))
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Email </div></th>
<th width="97"> <div align="center">CountryCode </div></th>
<th width="59"> <div align="center">Budget </div></th>
<th width="71"> <div align="center">Used </div></th>
</tr>
<?php
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?php echo $objResult["CustomerID"];?></div></td>
<td><?php echo $objResult["Name"];?></td>
<td><?php echo $objResult["Email"];?></td>
<td><div align="center"><?php echo $objResult["CountryCode"];?></div></td>
<td align="right"><?php echo $objResult["Budget"];?></td>
<td align="right"><?php echo $objResult["Used"];?></td>
</tr>
<?php
}
?>
</table>
<?php
mysql_close($objConnect);
?>
ขอบคุณครับล่วงหน้า
Tag : PHP, MySQL, Windows, Linux, Mac
|
|
 |
 |
 |
 |
Date :
2014-10-23 12:19:03 |
By :
doanga2007 |
View :
1638 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |