0

Hi everyone i am new to PHP, is there any PHP code to redirect website to avoid sql injection if someone put quot sign like this

www.site.com/page.php?id=22'

here is website http://www.dgqadefence.gov.in/inner.php?id=566'

when i try to put ' site redirecting to http://www.dgqadefence.gov.in/index.php

i need code , thanks

bigsmoke
  • 101
  • 1
  • 1
  • 5
  • You need to use Mod Rewrite to write you URL but that is not enough. If you are using your parameter `id` for db operations then you will need to use MySQLi with prepared statement – OPMat Apr 21 '18 at 14:41
  • Possible duplicate of [How to make a redirect in PHP?](https://stackoverflow.com/questions/768431/how-to-make-a-redirect-in-php) – sticky bit Apr 21 '18 at 14:43
  • You could easily use this code: `if (strpos($_GET["id"], '\'') !== false) { //code is safe } else { header("Location: http://www.example.com/"); die(); }` – Mustafa Al Ameen Apr 21 '18 at 14:43

0 Answers0