Jump to content

using header(Location) for redirect fails.


Lassie

Recommended Posts

header() statements can only be used before any content has been sent to the browser (content being anything other than a header.)

 

do you have php's error_reporting set to E_ALL and display_errors set to ON so that php would be displaying an error when you have tried to use a header() after content has been sent to the browser?

 

lastly, .html files by default are not passed to the php language engine to even parse the php code in it. have you configured your sever to invoke php for the .html file extension?

Link to comment
Share on other sites

Looking at your code, I can confirm what mac_gyver said: you need to restructure your code to have header() be called before any output.  Also, you will need to add exit(); immediately after the redirect, so that php will stop parsing/outputting the rest of the script. 

 

couple of sidenotes:

 

- mysql_xxx functions are deprecated. You should at a minimum update your mysql functions to use the mysqli syntax. It has both object oriented and procedural syntax.  The procedural syntax is very similar to the mysql procedural syntax you already used, so updating it is relatively painless. Better yet, look into using prepared statements, like with the PDO class. 

 

- I see a comment in your code to sanitize the user input but you aren't actually doing that.  If you do not validate/sanitize the user input, you are begging for your site to be hacked.  Switching to prepared statements will take care of this, but at a minimum you should be validating that the data is expected format/values. 

Link to comment
Share on other sites

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.