Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Can't pass data via URL to another script
Old 04-11-2009, 04:46 PM Can't pass data via URL to another script
Average Talker

Posts: 21
Trades: 0
I have boiled the problem down to a simple example and still don't understand the stupid mistake I must be making.

Trying to send data back to another page which will use it via a $_GET['some_data'] variable.

The problem is, my form works but the "some_data" does not get appended to the URL, only the question mark. Here's the simple HTML...
Code:
<HTML>
<HEAD>
<TITLE>test send back</TITLE>
</HEAD>
<BODY>

The URL that gets sent when button is pushed should be "foo.php?some_data"<br>
but the "some_data" gets left off.

<form action="foo.php?some_data"> 
<INPUT TYPE="SUBMIT" VALUE="continue">
</form>

</body>
</html>
My "foo.php" script never sees that data I am trying to pass to it.
jimandy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-11-2009, 05:12 PM Re: Can't pass data via URL to another script
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Use a hidden field:
PHP Code:
<html>
<
head>
<
title>test send back</title>
</
head>
<
body>

The URL that gets sent when button is pushed should be "foo.php?some_data"<br>
but the "some_data" gets left off.

<
form action="foo.php" method="post"
<
input type="hidden" value="value" name="some_data" />
<
input type="submit" value="continue" />
</
form>

</
body>
</
html
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-11-2009, 06:09 PM Re: Can't pass data via URL to another script
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
The problem of using a form without the method defined is sent using the get method automatically by the browser, and using your code above as an example, the some_data get parameter is being overwritten by the form input values.

If you specifiy post as the form method, the form input data will not overwrite your get params in the form action url.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-12-2009, 11:59 AM Re: Can't pass data via URL to another script
Average Talker

Posts: 21
Trades: 0
Thanks mgraphic,

I wanted to use GET method so I could observe the data sent to the target script via the URL. This worked:
Code:
<form name="input" action="foo.php" method="get">

<input type="hidden" name="something" value="this_thing" />
<input type="submit" value="do it" />

</form>
Things like this seem so simple once figured out.
jimandy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Can't pass data via URL to another script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.27425 seconds with 12 queries