Jump to content

[SOLVED] why isn't this posting?


Zeradin

Recommended Posts

It's driving me crazy. I just modified a shoutbox I made that worked and now it's not inserting the data into the tables.

if(isset($_POST['shout'])) {
$name = addslashes($_POST['name']);
$message = addslashes($_POST['message']);


$shoutquery = "INSERT INTO ybcomments (name, message, photoid) VALUES ('$name', '$message', '$id')";
$shoutresult = mysql_query($shoutquery);

echo '<meta http-equiv="Refresh" content="0;url=prpyearbook.php?id='.$id.'">';		
}
echo '<form method="POST" action="prpyearbook.php?id='.$id.'">'; ?>
				<table><tr><td>
				<strong>Name</strong></td><td>::</td><td>
				<input type="text" name="name" size="15"></td>
				<td><strong>Message</strong></td><td>::</td><td>
				<input type="text" name="message" size="35"></td><td></td><td></td><td><input type="submit" value="Do It!" name="shout" class="btn" /></td><tr></table>

Link to comment
https://forums.phpfreaks.com/topic/139148-solved-why-isnt-this-posting/
Share on other sites

I made some non vital changes, mostly formatting, you can see them below.

 

But the only real problem I see is no closing form tag.  Also the meta tag has to be in the header.  I was thinking maybe you simplified the code to post it here.  But maybe you did not.

 

Also, where is $id coming from?

 

<?php
if(isset($_POST['shout'])) 
{
$name = mysql_real_escape_string($_POST['name']);
$message = mysql_real_escape_string($_POST['message']);

$shoutquery = "
	INSERT INTO 
		ybcomments 
	SET
		name = '$name',
		message = '$message', 
		photoid = '$id'
";
$shoutresult = mysql_query($shoutquery);

// NOTE: this has to be in the header
echo '<meta http-equiv="Refresh" content="0;url=prpyearbook.php?id='.$id.'">';      
}
?>
<form method="POST" action="prpyearbook.php?id=<?php echo $id ?>">
<table>
	<tr>
		<td><strong>Name</strong></td>
		<td>::</td>
		<td><input type="text" name="name" size="15" /></td>
		<td><strong>Message</strong></td><td>::</td>
		<td><input type="text" name="message" size="35" /></td>
		<td> </td>
		<td> </td>
		<td><input type="submit" value="Do It!" name="shout" class="btn" /></td>
	<tr>
</table>
</form>

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.