0

I have a form on my page, and I want to send the user to the 'private' part of the page when they've submitted the form.

I want to achieve this by using sessions, but I can't find out how to set a session variable when the form is submitted. This is because the form action is an external page, and when it has been submitted it gets sent back to the page where the form is. The problem is however that I cannot catch that with HTTP_REFERER because it's an https page.

So i have no idea how to do this. Anybody? Thx!

6
  • 1
    what u have done so far?? paste your code atleast Commented May 24, 2011 at 7:26
  • Nothing really, just an idea so far. Commented May 24, 2011 at 7:29
  • But it will be something like this: <?php session_start(); if $_SESSION['submit'] == 1 { //show secret stuff } else { //show form } and I want to turn the submit session var into 1 when they press submit Commented May 24, 2011 at 7:31
  • do you know how to start a session and set a variable? Commented May 24, 2011 at 7:31
  • @priktop your missing ya parenthesis's Commented May 24, 2011 at 7:34

1 Answer 1

1

A couple ways I can think of doing this:

  1. Send the form to a local page that sets the session variable and then fopen()'s the remote page. Here's a post describing how to send POST data with PHP streams.

  2. Use AJAX and the onbeforesubmit JavaScript hook. Basically, when the user clicks submit, cancel the form submission, send your AJAX request to your own server, then when it returns, submit the form. Make sure to disable the form submit button when you do this, as it could take some time for the round trip to your server.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Morgan, I'll go with your AJAX solution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.