Skip to content

Instantly share code, notes, and snippets.

@virusdefender
Created May 15, 2016 03:24
Show Gist options
  • Save virusdefender/b1f9876d53706534c221f386b568bd9f to your computer and use it in GitHub Desktop.
Save virusdefender/b1f9876d53706534c221f386b568bd9f to your computer and use it in GitHub Desktop.
sqli.php
<?php
header("Content-type: text/html;charset=gbk");
define("HOST",'127.0.0.1');
define("USER",'root');
define("PASS",'testtest');
define("DB",'test');
foreach($_GET as $key => $val){
$_GET[$key] = addslashes($val);
}
$conn=mysql_connect(HOST,USER,PASS) or die('<center><h2>Could not connect:'.mysql_error()."</h2></center>");
mysql_select_db(DB,$conn);
mysql_query("set names 'gbk'");
$id=$_GET['id']?$_GET['id']:'1';
$sql="select * from article where id='$id'";
$result=mysql_query($sql) or die(mysql_error());
if ($result){
$row = mysql_fetch_array($result);
echo "<center><h1>".$row['content']."</h1></center>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment