Log in

View Full Version : POST and redirects



james438
11-10-2010, 07:14 PM
I have a form where I send info from a login page to a validation page using POST. If the values on page 2 do not validate there is a javascript snippet to redirect to page 1. If the values do validate then the user is redirected via javascript to the user control panel. The user never really sees the login validation page. How do I send the failed values back to page 1 using POST? I can use GET, but I am trying to figure out what I am doing wrong with POST.

If you need more, let me know.

bluewalrus
11-10-2010, 07:52 PM
Why not validate on the same page or via ajax?

james438
11-10-2010, 08:23 PM
not really familiar with ajax. The values are stored in a database.

bluewalrus
11-10-2010, 08:54 PM
Okay, I'd validate on the same page than, you should still be able to get the values from the DB when the page is reprocessed with the POST data.

I'm not familiar with this but it sounds like it could work as well http://pear.php.net/manual/en/package.http.http-client.http-client.post.php

james438
11-11-2010, 12:14 AM
I think that the best way to do this would be to use cookies or, better yet, sessions. Getting addons for php seems a bit much work for this project. I'm just trying to see if I am missing something simple about POST. POST is used to send info from one page to another, but why not from the first to the second to the third? I figure there should be a way to propagate the POST via a command line in page 2.

Schmoopy
11-11-2010, 12:25 AM
The POST array is created by a form submission, that's why you can't use really use it for the second page. If you don't want to use cookies or sessions, maybe something like this:

Loop through the $_POST array, figure out whether it's valid or not, then submit a dynamically generated form via javascript when you're done.

The above is a very long winded way of doing it.

Validating the form on the same page is a much easier way of doing this, what is the need in the script going to a second page?

Nile
11-11-2010, 12:35 AM
Check out cURL (http://php.net/manual/en/book.curl.php) and then check out a nice cURL tutorial (http://davidwalsh.name/execute-http-post-php-curl). :D