|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
_POST not working with form
I'm having trouble gettting my _POST to grab the variables from the initial page onto the secondary page.
The initial page consists of a form that reloads itself upon submission to validate client side. If the validation is succesful then the page redirects to the secondary page using javascript. The second page can not pick up the variables unless I change the action of the form to that page itself. Am I doing something wrong? Here is some of the code: PHP Code:
And trying to grab them on the second page for processing: PHP Code:
I tried using just _POST becuase I read that the http_post_vars was a little antiquated, but the result was the same. Thanks for your help! -Tyler Last edited by p8ball4life : May 13th, 2008 at 09:50 AM. |
|
#2
|
||||
|
||||
|
the post wont carry to the second page. you posted to the first page, that's where the post variables are available. When you redirect they go away. If you want to maintain your current scheme I would suggest storing the $_POST vars in the $_SESSION then reading and cleaning them on the second page.
so on page1 before you redirect do this $_SESSION['p1Post'] = $_POST; then on page two you can retrieve the vars from $_SESSION['p1Post'] dont forget to do session_start(); at the top of both of the pages.
__________________
There is no spoon. |
|
#3
|
|||
|
|||
|
You start your form here
<form method="post" action="page1.php" name="xform"> So your next page should be page1.php to receive the posts |
|
#4
|
|||
|
|||
|
I read into sessions, but decided to simply migrate the processing from page2 into page1.
Is there any reduced security involved with this? |
|
#5
|
||||
|
||||
|
no but it leads to spaghetti code. As you become a more sophisticated programmer and start coding more complicated projects you will not want to do this. The trend is to separate out your display from your logic and database interaction. Putting it all on one page will work but it will get complicated and reduce the reuseablilty of your code.
That having been said, who cares. If you can make it work then make it work. You can fix it later, you won't, but you can. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > _POST not working with form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|