Reply
Getting load variable after submitting a form
Old 11-12-2004, 12:37 PM Getting load variable after submitting a form
Skilled Talker

Posts: 79
EDIT: have fixed my own problem. sorry.

Hello

I would like to know how to pass on a variable after a person submits a form, so that I can use a "switch" command in the page.

For example, what I do with my webpages is have each URL called <a href="index.php?load=contactme"> or <a href="index.php?load=homepage"> and the index.php page has a switch command saying to get the load variable and then to include a specific bit of text.

This works perfectly for all URLs.

However, I want to do exactly the same thing when someone fills in a form and presses "submit", but I can't figure out what to do.

I have my form:

PHP Code:
<form action="index.php" method="post">
<
input type="text" name="test_text" length="30">
<
input type="submit" name="submit" value="submit!">
</
form
and when the person presses submit want it to go to the index.php page and load a certain include. For example, one saying "Thanks for submitting."

In there anyway to pass a variable on the URL after pressing submit? For example, using a hidden field in the form? I tried index.php?load=thanks, but I don't remember it working.

Thanks in advance for you help.

Hamish

EDIT: for some reason action="index.php?load=thanks" is now working. Sorry to have bothered anyone.
__________________
http://www.iskm.com/backup/ secure and fully automated computer data backup for small and medium sized companies.

FREE OFFSITE BACKUP

Last edited by hamish : 11-12-2004 at 12:40 PM.
hamish is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-12-2004, 12:42 PM
foobar's Avatar
Extreme Talker

Posts: 225
Well, just use what you did before. Put "index.php?load=value" as the "action" in your form.

On index.php, retrieve the load variable using $_GET['load'], and then just use your switch like you intended.
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 11-12-2004, 01:05 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
A better way is to use the location() function. If there turns out to be a security problem with $_GET and $_POST vars in the future then you would open yourself up to an attack by including a page in that fashion.
Republikin is offline
Reply With Quote
View Public Profile
 
Old 11-12-2004, 03:35 PM
foobar's Avatar
Extreme Talker

Posts: 225
There's a location function? What's that do? Never heard of it!

But I doubt you'll run into a security problem by passing an action variable in the query string. It's not like he was passing a password or anything ...
foobar is offline
Reply With Quote
View Public Profile Visit foobar's homepage!
 
Old 11-12-2004, 03:46 PM
Republikin's Avatar
Super Moderator

Posts: 3,191
Oops I got messed up, what I meant was the header function. It is used like this...

header("Location: page.php");

Sending a get or post request to include a page is not inherently dangerous but it could be with sloppy coding or even simple mistakes. For instance someone could change what you intended from say page1.html to securepage.html. Possibly bypassing security measures.

It really depends on the person doing the coding and what kind of security measures are put into place. I have always just seen including pages by post or get variables as not the best programming practices. Ofcourse, best programming practices is always up for debate as everyone seems to have their own way to do things.
Republikin is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Getting load variable after submitting a form
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13038 seconds with 12 queries