HTTP Header with Location doesn't ID to the URL
I have a problem using a "header location", below is the code:
case 'update':
updateUser($_GET['ticket_id']);
开发者_如何学Python header('Location: ../ticket/listOfTicket.php?ticket_id='.$_GET['ticket_id'].'');
exit;
break;
I'm using case
because want to I update into a database. The problem here I believe is:
header('Location: ../ticket/listOfTicket.php?ticket_id='.$_GET['ticket_id'].'');
I don't know where to put the quote '
and "
. It will outputted in the URL like this:
http://localhost/ticket/listOfTicket.php?ticket_id=
It didn't display the ticket_id. Why?
You should always sanitize your user input. I could easily pass something you're not expecting to $_GET['ticket_id']. Assuming ticket_id is an integer, this works for me when I access the page and set ticket_id to some value.
header( 'Location: ../ticket/listOfTicket.php?ticket_id=' . intval( $_GET['ticket_id']));
exit;
精彩评论