Jump to content

[SOLVED] variable getting erased


blueman378

Recommended Posts

hi guys, well heres the entire code,

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Edit Comment</title>
<style>
.title
{
vertical-align:top;
text-align:left;
font-weight:bold;
}
</style>
</head>

<body bgcolor="#999999" style="font-size:16px; font-family:Arial;">
<?
$idedit=$_GET['idedit'];
include("connect.php");
@mysql_select_db("b13_1476306_my_db") or die("Unable to select database");
$out="SELECT * FROM comments WHERE id='$idedit'";
$output=mysql_query($out);
mysql_close();

$id=mysql_result($output,$x,"id");
$name=mysql_result($output,$x,"name");
$email=mysql_result($output,$x,"email");
$comment=mysql_result($output,$x,"comment");
$date=mysql_result($output,$x,"date");
?>

<form method="post" action="commentsadminedit21.php">
<table>
<input type="hidden" name="id_edit" size="40" disabled="disabled" <? echo "value=\"$id\""; ?>>
<tr>
<td class="title">
Name: 
</td>
<td>
<input type="text" name="name_edit" size="40" <? echo "value=\"$name\""; ?>>
</td>
</tr>

<tr>
<td class="title">
E-Mail Address: 
</td>
<td>
<input type="text" name="email_edit" size="40" <? echo "value=\"$email\""; ?>>
</td>
</tr>

<tr>
<td class="title">
Comment: 
</td>
<td>
<textarea name="comment_edit" cols="35" rows="6"><? echo $comment; ?></textarea>
</td>
</tr>

<tr>
<td class="title">
Date: 
</td>
<td>
<input type="text" name="date_edit" size="40" <? echo "value=\"$date\""; ?>>
</td>
</tr>


<tr>
<td>
</td>
<td align="center">
<input type="submit" value="Submit">
</td>
</tr>

</table>
</form>
<p>
<?
echo echo $_POST["id_edit"];
$id_edit=$_POST['id_edit'];

$name_edit0=$_POST['name_edit'];
$name_edit=filter_var($name_edit0, FILTER_SANITIZE_STRING);

$email_edit0=$_POST['email_edit'];
$email_edit=filter_var($email_edit0, FILTER_SANITIZE_STRING);

$comment_edit0=$_POST['comment_edit'];
$comment_edit=filter_var($comment_edit0, FILTER_SANITIZE_STRING);

$date_edit0=$_POST['date_edit'];
$date_edit=filter_var($date_edit0, FILTER_SANITIZE_STRING);

if(isset($_POST['name_edit']))
{

include("connect.php");
@mysql_select_db("b13_1476306_my_db") or die("Unable to select database");

$insert="UPDATE comments SET name='$name_edit', email='$email_edit', comment='$comment_edit', date='$date_edit' WHERE id='$id_edit'";
if (mysql_query($insert))
{
die("SQL:<br>$insert");
}
else
{
echo "<span class=\"alert\">Unable to edit comment.</span>";
}
mysql_close();

}
else
{
echo "Edit data that you wish to change and make sure that all the fields are filled. Then click Submit.";
}
?>
<p>
<a href="http://rowno.byethost13.com/commentsadmin22.php">Back to main comments page</a>
</body>
</html>

 

but when it is run using a link such as http://rowno.byethost13.com/commentsadminedit21.php?idedit=12

 

we get

UPDATE comments SET name='Roland Warmerdam', email='[email protected]', comment='Test', date='04/02/2008 09:39 am' WHERE id=''

notice that where is empty any ideas why it is not being recoreded?

Link to comment
https://forums.phpfreaks.com/topic/89343-solved-variable-getting-erased/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.