Reputation: 23
When you hit the "Post" button it should send the data to the database and redirect you to ?success=true but it will not redirect you or send the data to the DB.
This is suppose to do the redirecting and function calling:
if (empty($_POST['postBox']) === false && $_GET['success'] != true){
sendPost();
header("LOCATION: /offtopic.php?success=true");
exit();
}
This is sendPost:
function sendPost()
{
$postBox = '\'' . htmlentities(mysql_real_escape_string($_POST['postBox'])) . '\'';
$user_id = $_SESSION['user_id'];
mysql_query("INSERT INTO `offtopicposts` (user_id, post, reported) VALUES ($user_id, $postBox, 0)") or die(mysql_error());
}
EDIT: You can log in to the off-topic page with the username: Test and password: Test123456789
Upvotes: 0
Views: 54
Reputation: 23
I am so sorry... Because of the new background I was unable to see the error... In the DB something wasn't allowed to be null... So a quick fix and its working... Thank you all for the help!
Upvotes: 0
Reputation: 4142
put a return statement in function
function sendPost()
{
$postBox = '\'' . htmlentities(mysql_real_escape_string($_POST['postBox'])) . '\'';
$user_id = $_SESSION['user_id'];
mysql_query("INSERT INTO `offtopicposts` (user_id, post, reported) VALUES ($user_id, $postBox, 0)") or die(mysql_error());
return;
}
Upvotes: 1
Reputation: 442
Try this if condition
if (!empty($_POST['postBox']) && $_GET['success'] != 'true')
Upvotes: 0