Jump to content
MakeWebGames

Recommended Posts

Posted

Basically i need a Report button to show on each forum thread, kind of like this:

 

<form action='forums.php' method='post'>
<input type='hidden' name='fp_poster_id' value='{$r['fp_poster_id']}'>
<input type='hidden' name='fp_id' value='{$r['fp_id']}'>
<input type='hidden' name='fp_text' value='{$r['fp_text']}'>
<input type='submit' value='Report'>
</form>

 

If someone could just post up the rest of the code just so when someone clicks the button it prints "Post has successfully been reported" and inserts it into the database.

Thanks for any help anyone can give :) 8)

Posted

Something along these lines, untested of course.

$_POST['fp_poster_id'] = abs((int) $_POST['fp_poster_id']);

$_POST['fp_id'] = abs((int) $_POST['fp_id']);

$_POST['fp_text'] = mysql_real_escape_string(strip_tags($_POST['fp_text']));

 

if(isset($_POST['fp_poster_id']) && isset($_POST['fp_id') && isset($_POST['fp_text']))

{

$poster = $_POST['fp_poster_id'];

$postid = $_POST['fp_id'];

$posttext = $_POST['fp_text'];

$db->query("INSERT INTO forumreport VALUE('',$poster, postid, posttext)");

echo 'Post successfully reported';

}

else

{

echo "

<form action='forums.php' method='post'>

<input type='hidden' name='fp_poster_id' value='{$r['fp_poster_id']}'>

<input type='hidden' name='fp_id' value='{$r['fp_id']}'>

<input type='hidden' name='fp_text' value='{$r['fp_text']}'>

<input type='submit' value='Report'>

</form>";

}

Posted

change

 

if(isset($_POST['fp_poster_id']) && isset($_POST['fp_id') && isset($_POST['fp_text']))

 

into

 

if(isset($_POST['fp_poster_id']) && isset($_POST['fp_id']) && isset($_POST['fp_text']))

 

he just missed one ]

Posted

Thank you both for help, i now have the main code all fixd and nearly working:

 

$_POST['fp_poster_id'] = abs((int) $_POST['fp_poster_id']);
$_POST['fp_id'] = abs((int) $_POST['fp_id']);
$_POST['fp_text'] = mysql_real_escape_string(strip_tags($_POST['fp_text']));


if(isset($_POST['fp_poster_id']) && isset($_POST['fp_id']) && isset($_POST['fp_text']))
{
echo "
<form action='forums.php' method='post'>
<input type='hidden' name='fp_poster_id' value='{$r['fp_poster_id']}'>
<input type='hidden' name='fp_id' value='{$r['fp_id']}'>
<input type='hidden' name='fp_text' value='{$r['fp_text']}'>
<input type='submit' value='Report'>
</form>";
}
else
{
$poster = $_POST['fp_poster_id'];
$postid = $_POST['fp_id'];
$posttext = $_POST['fp_text'];

$db->query("INSERT INTO freports VALUE('', '$poster', '$postid', '$posttext')");
echo 'Post successfully reported';
}
print "</td>
<td valign=top class='forumb'>{$r['fp_text']}
{$edittext}

</td>
</tr>";
}

 

However: When i click the button it just takes me to forums.php instead of reporting the forum.

Posted

Because you changed what I had up

:P

Basically you are telling it if the $_POST variable is set to send you back to the form :P

There's a reason it was laid out like it was (=

And I dno what it is with me and programming i ALWAYS miss the ending ] or a ; somewhere.

Posted

You would probably need to change the variables then, if you are using the same variables it will do that

Define unique variables for the forum report button, maybe keep the poster_id the same

Posted

I dont have any custom fields i have all the same from the default mccodes forum but when i visit a forum say theres 10 posts in there, they are all reported by me then instead of me having to click the button, the way i laid it out it now displays the button but when i click it, i just stay on the same page and its like it isn't submitting. Appreciate the help by the way :)

Any ideas whats wrong here?

Posted

What's wrong is the <form> box you are using is using the same 'name' variable as your forums use, so they are staying set

rename the form boxes and the $_POST variables to something else :)

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.   Paste as plain text instead

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