Jump to content

[SOLVED] Quick question - Need help with $id


3raser

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."!";
}     
}                                                     
?>

Archived

This topic is now archived and is closed to further replies.

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