I am trying to search mysql databse and display it in an editable form and then update records. I can search and display data in a form. But when I am trying to update data not going to the database. If any one can help me please have a look at my script. I have search.php and update.php two separate files. Can I have both in one file? Thank you in advance
This is Search.php
<?
$db_host="localhost";
$db_name=" ";
$db_user=" ";
$db_pass=" ";
$conn=mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
mysql_select_db("$db_name");
?>
<html>
<head>
<meta name="description" content="Php Code Search & Display Record" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<form name="search" method="post" action="search.php">
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="0">
<tr>
<td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize:
20px">Search</td></tr>
<tr>
<td width="140">Enter Search Keyword</td>
<td width="240"><input type="text" name="search" size="40" /></td>
<td width="665"><input type="submit" value="Search" /></td>
</tr>
<tr bgcolor="#666666" style="color:#FFFFFF">
<td>Record ID</td>
<td>Description</td>
<td> </td>
</form>
<?php
$search=$_POST["search"];
$conn=mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
mysql_select_db("$db_name");
$result=mysql_query("SELECT * FROM table WHERE SO like '%$search%'")or die(mysql_error());
while ($row= mysql_fetch_array($result) ){
?>
<FORM ACTION="update.php" METHOD=POST>
<input type="text" name="RID" value="<?php echo $row['RID'];?>" size=6>
Author
<input type="text" name="author" value="<?php echo $row['AU'];?>">
Title
<input type=text name="title" value="<?php echo $row['TI']; ?>" size=30>
Source
<input type=text name="source" value="<?php echo $row['SO']; ?>" size=40>
Fulltext Link
<input type=text name="fultext" value="<?php echo $row['fultext']; ?>" size=40> <input type=submit name="submit" value="Update"></p><br>
</form>
<?php
}
?>
</table>
</form>
</body>
</html>
This is update.php
<html>
<head>
<title>Update a Record in MySQL Database</title>
</head>
<body>
<?php
$db_host="";
$db_name="";
$db_user="";
$db_pass="";
$conn=mysql_connect($db_host, $db_user, $db_pass) or die (mysql_error());
mysql_select_db("$db_name");
$RID=$_POST['RID'];
$AU=$_POST['AU'];
$SO=$_POST['SO'];
$FULTEXT=$_POST['FULTEXT'];
$query="update table SET AU='$AU', SO='$SO',FULTEXT='$FULTEXT' WHERE RID=$RID";
mysql_query($query);
echo "<center>Successfully Updated in DATABASE</center>";
include("search.php");
?>
</body>
</html>