Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 325827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:15:11+00:00 2026-05-12T09:15:11+00:00

EDIT: So my remaining questions are: (1) should I use a 302 or 303

  • 0

EDIT:

So my remaining questions are: (1) should I use a 302 or 303 for the header() redirect? I believe 303 is the proper way. (2) Is $_SESSION the best way to pass variables to the ?contact=thankyou page?

My revised code:

if ( isset( $_POST[ 'submit' ] ) )
{
  if ( is_bot() )
  {
    header( "Location: http://www.example.com/contact/?contact=thankyou",
        TRUE, 303 );
    exit;
  }
  elseif ( is_input_error() )
  {
    // show error form stuff...
  }
  else
  {
    contact_send_email();
    header( "Location: http://www.example.com/contact/?contact=thankyou",
        TRUE, 303 );
    exit;
  }
}

ORIGINAL (resolved):

I am just learning about $_POST, $_GET and forms with PHP. I have a Contact Form that started out simple, but has now become a little complicated for my experience.

// curly braces left out for brevity
if ( isset( $_POST[ 'submit' ] ) )
  if ( is_bot() )
    header( "Location: http://www.example.com/contact/?contact=thankyou", 
            TRUE, 303 );
  if ( is_input_error() )
    header( "Location: http://www.example.com/contact/?contact=error", 
            TRUE, 303 );
  else
    contact_send_email()
    header( "Location: http://www.example.com/contact/?contact=thankyou", 
            TRUE, 303 );
  1. Being new at this, I guess I’d like to know if you see any glaring problems?
  2. Does my header() redirect code look complete and valid?
  3. What is the most common and/or recommended way to pass $_POST variables after the header() redirection? Is it with $_SESSION, or is there a better way? I’ve never used sessions before, so I am a little intimidated by them.

EDIT: By the way, I want to pass the header() redirect with $_GET to avoid the “refresh-resend” very scary and evil warning message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:15:11+00:00Added an answer on May 12, 2026 at 9:15 am

    1st question. I would suggest to use brackets { } after if, because your conditional blocks look invalid.

    2nd question. I don’t think you need 303 status code. A typical header('Location: ...'); will do.

    As for 3rd question. Two possible solutions are: session or database.

    To sum up, I’d do:

    if ( isset( $_POST[ 'submit' ] ) )
    {
      if ( is_bot() )
      {
        header( "Location: http://www.example.com/contact/?contact=thankyou" );
      }
      elseif ( is_input_error() )
      {
        header( "Location: http://www.example.com/contact/?contact=error" );
      }
      else
      {
        contact_send_email();
        header( "Location: http://www.example.com/contact/?contact=thankyou" );
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Should developers be limited to certain applications for development use? For most, the answer
Anyone know of a way to remove the main editor from the page edit
Edit: Posted on Audio/Video Production site https://video.stackexchange.com/questions/4148/creating-midi-files-explanation-of-time-division-in-header-chunk I've been reading about MIDI file structure
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important
EDIT: iam using ajax to load text in my content that is why onload
Edit : Note that, as Daniel and latkin noted in an answer and a
EDIT : It turned out that this can only be done through an external

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.