VitalEnd Posted October 9, 2010 Posted October 9, 2010 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) Quote
Joshua Posted October 10, 2010 Posted October 10, 2010 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>"; } Quote
VitalEnd Posted October 10, 2010 Author Posted October 10, 2010 Parse error: syntax error, unexpected ')', expecting ']' in /home/vitalend/public_html/forums.php on line 363 Quote
Dominion Posted October 10, 2010 Posted October 10, 2010 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 ] Quote
VitalEnd Posted October 10, 2010 Author Posted October 10, 2010 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. Quote
Joshua Posted October 10, 2010 Posted October 10, 2010 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. Quote
VitalEnd Posted October 10, 2010 Author Posted October 10, 2010 Yeah but the way you laid it out when i visited the forum every topic was reported .... Quote
Joshua Posted October 10, 2010 Posted October 10, 2010 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 Quote
VitalEnd Posted October 10, 2010 Author Posted October 10, 2010 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? Quote
Joshua Posted October 10, 2010 Posted October 10, 2010 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 :) Quote
VitalEnd Posted October 10, 2010 Author Posted October 10, 2010 Well ive tried that and failed lol... if your up for doing it ill send you a couple of $$ if you can :) msn: [email protected] :thumbup: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.