Jump to content

Recommended Posts

Alright, when someone clicks [REPORT] on the index.php, they go to report.php?=id - But how do I get the ID from the URL? Like I click [REPORT] on post id 55 and I go to report.php?=55, how does the page know that it's ID 55?

 

Here's my code:

 

<?php require("global_navigation.php"); ?>
<?php

$name = $_SESSION['username'];
$id = $_POST['id'];
                                                                                      {
if ($_SESSION['username'])
  {

if (!$id)
   die("You cannot visit this page from your browser address! You must report a post first!");

$ip = $_SERVER['REMOTE_ADDR'];

//protection
$before = array('^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE');
$after   = array('', '', '', '', '', '', '', '', '', '', '');
$output  = str_replace($before, $after, $message);

$connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!");
mysql_select_db("$db") or die("Database fail!");
           

//connect
$connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!");
mysql_select_db("$db") or die("Database fail!");

//write
$write = mysql_query("INSERT INTO reports VALUES ('','$id','$name')") or die(mysql_error());

echo "<div class='box'><font face='arial'><b><span style='color:green'>Successfully reported post ID ".$id."!";
}     
}                                                     
?>

Link to comment
https://forums.phpfreaks.com/topic/180729-solved-quick-question-need-help-with-id/
Share on other sites

Now when I click it, it still says the error message when id = !$id.

 

<?php require("global_navigation.php"); ?>
<?php

$name = $_SESSION['username'];
$id = $_GET['id'];
                                                                                      {
if ($_SESSION['username'])
  {

if (!$id)
   die("You cannot visit this page from your browser address! You must report a post first!");

$ip = $_SERVER['REMOTE_ADDR'];

//protection
$before = array('^', '<', '>', '`', '*', '<script>', '</script>', ';DROP TABLE users;', 'users', 'DROP', 'TABLE');
$after   = array('', '', '', '', '', '', '', '', '', '', '');
$output  = str_replace($before, $after, $message);

$connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!");
mysql_select_db("$db") or die("Database fail!");
           

//connect
$connect = mysql_connect("$dbhost","$dbuser","$dbpassword") or die("Connection failed!");
mysql_select_db("$db") or die("Database fail!");

//write
$write = mysql_query("INSERT INTO reports VALUES ('','$id','$name')") or die(mysql_error());

echo "<div class='box'><font face='arial'><b><span style='color:green'>Successfully reported post ID ".$id."!";
}     
}                                                     
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

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

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

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.