Ok, I was wanting users to be able to post their comments on something on my website. The form works and it INSERTs into the database. However, it submits the form twice for some odd reason.
So when I check the database articles, I see 2 of every report.
From looking at my code, do you see anything I am doing wrong?
<?PHP
$con = mysql_connect("localhost","dbuser","dbpass");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("versionx_recruit", $con);
$ip=$REMOTE_ADDR;
$sql="INSERT INTO comments (appid, comment_from, comment, poster_ip)
VALUES
('$_POST[appid]','$_POST[comment_from]','$_POST[comments]','$_POST[poster_ip]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
if (mysql_query($sql))
echo "Your comment has been posted. Currently, comments are not viewable by clan members. This will be released in the next update. Thanks for your submission! You will be directed to the forums in 3 seconds.";
else
echo 'Error submitting form';
mysql_close($con)
?>
<form id="comment" name="comment" method="post" action="comments.php">
<input id="poster_ip" name="poster_ip" value='<?php echo $_SERVER["REMOTE_ADDR"]?>' type='hidden'>
<input id="appid" name="appid" value='<?php echo $appid ?>' type='hidden'>
<strong>Your Name (Note: IP is recorded)</strong><br />
<label for="comment_from"></label>
<input type="text" name="comment_from" id="comment_from" />
<p><strong>Have something worth commenting on this application? Please add it here!</strong>
</p>
<p>
<textarea name="comments" id="comments" cols="50" rows="10"></textarea>
</p>
<p>
<input type="submit" name="process" id="process" value="Submit post" />
</p>
</form>
Thanks,
Doc