Results 1 to 4 of 4

Thread: How to declare the header() function in php?

  1. #1
    Join Date
    Nov 2008
    Posts
    73

    How to declare the header() function in php?

    I want to be able to check whether or not a user has certain permissions to be on that page. But this code is included after I've already done some echo statements. I use the following code to redirect the browser on an error,

    header("location:error.php");
    exit;

    If a file is submitted in the header function is used it refuses to recognize the variables and thus goes to the wrong page. Is it possible to pass POST variables on as if a form was submitted, using header()?

  2. #2
    Join Date
    Oct 2008
    Posts
    134

    Re: How to declare the header() function in php?

    However, up until PHP 4.4.2 / PHP 5.1.2 it was prone to injection attacks. to prevent from rewriting a lot of your code, I would borrow an idea from Joomla... instead of using header() directly to redirect, run a function instead. then you just runt he function with the URL as a parameter.. If you used a variable within the parameter and your user could set that variable to include a new line character, he could add in any other header at all.

  3. #3
    Join Date
    Dec 2008
    Posts
    161

    Re: How to declare the header() function in php?

    The HyperText Transfer Protocol (HTTP) is the language that Web servers and Web clients use to talk to each other over the Internet. PHP's header() can be used to send raw, arbitrary HTTP headers. The main thing to rememeber with the header function is that it must be the first thing that sends output in you script. If it is not, you will receive the "headers already sent" error. The output can include error messages or simply a blank line before your initial <?php statement.

  4. #4
    Join Date
    Mar 2008
    Posts
    349

    Re: How to declare the header() function in php?

    If a file is submitted in the header function is used it refuses to recognize the variables and thus goes to the wrong page. One of the many handy uses for this is if you have a site and you wish to track "click outs". You create an link on your site to an internal page, and then use the redirect to forward the user on the external site by either passing the new site in the URL or by passing a reference to a database which store the site addresses. I have echoed these variables before and commented out the header function and they are fine. As a work around Ive had to code a function that redirects using javascript.

Similar Threads

  1. Connect USB 3.0 front case panel header to motherboard w/o a header?
    By Dogs-Day-Out in forum Motherboard Processor & RAM
    Replies: 4
    Last Post: 14-04-2012, 07:02 PM
  2. What is the Declare Construct in PHP?
    By Rob Dizzle in forum Software Development
    Replies: 5
    Last Post: 06-03-2010, 03:51 AM
  3. How to declare a cotaskmemfree
    By Patrickboy in forum Software Development
    Replies: 3
    Last Post: 24-06-2009, 12:09 PM
  4. IIS7: Add expires header or cache-control header
    By quota in forum Software Development
    Replies: 3
    Last Post: 06-06-2009, 07:45 PM
  5. How to declare print function in PHP
    By Aanand in forum Software Development
    Replies: 3
    Last Post: 29-05-2009, 12:28 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,031,331.85365 seconds with 17 queries