Redirecting after login?  | |
July 6th, 2003, 02:43 AM
|
#1 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Chattanooga, TN
Posts: 660
|
I have a form in PHP that I want to redirect after successfull input.
Here is how the form is currectly working, or at least how I understand it.
The form has several fields and two are required. When the user hits submit, the page loads itself. It then checks and validates the required fields are met. If not it prompts the user for the missing field.
If it is correct, it performs a mySQL INSERT. Then returnsto the same form.
My question is after a successful input how can I tell it to forward/redirect to another page?
I'm not sure if this is enough info, but I can provide more if necessary.
Thanks,
LK |
| |
July 6th, 2003, 02:59 AM
|
#2 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Chattanooga, TN
Posts: 660
|
I found the header() function, but I don't think it would work because the code for the update is after the headers have been outputted (I don't think that's a work).
Does anyone have an idea?
LK
(Just came up with an idea, I'm going to put the PHP code at the very top of the page, I don't think that will mess anything up. |
| |
July 6th, 2003, 12:14 PM
|
#3 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Chattanooga, TN
Posts: 660
|
Well, I guess it did work. Since I am using dreamweaver and templates I didn't think I could put the code at the top of the page, but apparently I can.
And it work. The only problem is that the url doesn't change it keeps the same page. It's not that big of a deal, but it reposts the same info if they refresh.
LK
__________________
Want a portrait, drawing, mural or any other custom art? Contact my wife Mindy Herman @ -http://www.mindyherman.com/
|
| |
July 6th, 2003, 10:41 PM
|
#4 (permalink)
| | Banned
Join Date: Oct 2001
Posts: 447
| Quote: |
I have a form in PHP that I want to redirect after successfull input... I found the header() function... The only problem is that the url doesn't change it keeps the same page.
| you can have the PHP script perform all you want without 'redirect's using header(). Not good to use after any PHP output, as you see with the url/post issue (not real redirect!).
try:
if ($firsttime)
{ //show form
}
else if ($formsubmit)
{ //check required
if ($goodinput)
{ //show results
}else
{ // prompts the user for the missing field
}
===
If you want to change the url for '$goodinput' but not the other stuff, you can(couple, if not a few ways), but you might want to rethink the flow of events/scripts. |
| |
July 8th, 2003, 02:23 PM
|
#5 (permalink)
| | Senior Member
Join Date: Oct 2001 Location: Chattanooga, TN
Posts: 660
|
Good point, I was using two different pages to perform this task, but I could put it into one page.
The only the the second page did was show the results from the db.
I'll give it a try.
Thanks,
LK |
| | | Thread Tools | Search this Thread | | | | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |