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='rolandwarmerdam@hotmail.com', 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.