Hi everyone,
I have the following form where I'm bringing information already stored on my database, so the user can modify them, but after the user make the changes and click on the button the changes made by that user are not getting updated.
Can anyone please help me?
This is my form where I bring the values:
require("mydatabase.php");
$id_fromclick=$_GET['id'];
$sql = "Select * from $tbl_name where id=$id_fromclick";
/*$sql="Select * from $tbl_name where id=$id_fromclick";*/
$result=mysql_query($sql) or die(mysql_error());
<form action="row_toedit.php" method="post" name="form1">
<table width="90%" height="193" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<tr>
<td><table width="100%" height="29" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="19%"> </td>
<td width="2%"> </td>
<td width="79%"><div align="right"><strong><a href="logmeout.php">
<input name="id" type="hidden" id="id" value="<?PHP echo $id_fromclick ?>" />
Log Out</a></strong></div></td>
</tr>
<?php $rows=mysql_fetch_array($result) ?>
<tr>
<td>Event Post Title</td>
<td><div align="center">:</div></td>
<td><input name="tittle" type="text" id="tittle" size="37" value="<?PHP echo $rows['tittle']; ?>"/></td>
</tr>
<tr>
<td>Your Name</td>
<td><div align="center">:</div></td>
<td><input name="author" type="text" id="author" size="37" value="<?PHP echo $rows['author']; ?>"/></td>
</tr>
<tr>
<td valign="top">Your Post</td>
<td valign="top"><div align="center">:</div></td>
<td><textarea name="post" cols="45" rows="12" id="post"><?PHP echo $rows['post']; ?></textarea></td>
</tr>
<tr>
<td>Date</td>
<td><div align="center">:</div></td>
<td><input name="date" type="text" id="date" size="37" value="<?PHP echo $rows['date']; ?>"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Update Sport" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
This is the page where I'm trying to update the values that I receive from my form page:
require("mydatabase.php");
$id_fromclick=$_POST['id'];
$tittle=$_POST['tittle'];
$author=$_POST['author'];
$post=$_POST['post'];
$date=$_POST['date'];
$query="UPDATE mydatabase SET tittle='$tittle',author='$author',post='$post',date='$date' WHERE id = '$id_fromclick'";
mysql_query($query);
mysql_close();