Be a Supporter!

a php question, i think its simple

  • 420 Views
  • 15 Replies
New Topic Respond to this Topic
rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
a php question, i think its simple 2006-11-05 19:01:34 Reply

is it possible to retrieve hidden inputs from forms and set them as variables?

such as

www.site.com?something=something

$something = $_POST('something');

I am not sure whether you would specify the name or the value in the variable, or if it would be $_POST, but can someone tell me how to do it?

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:20:10 Reply

I'm talking about for "input type='hidden''s." Would you define the names and the values? Would it be $_POST or something else?

harryjarry
harryjarry
  • Member since: May. 15, 2005
  • Offline.
Forum Stats
Member
Level 57
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:32:00 Reply

It would be $_POST if you had the form method as post, but if you set the form method as get it will be $_GET.

So it is up to you on how you want to retrieve them, but it is possible.


twitter | last.fm // Currently working on HarryJarry.com

BBS Signature
rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:35:44 Reply

thanks, i know what you mean but the reason I'm asking is because they're input type=hiddens. I don't know how they would be retrieved, or whether you would use the name or the value to set the variable.

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:38:11 Reply

i take it back, this question isn't that simple.

harryjarry
harryjarry
  • Member since: May. 15, 2005
  • Offline.
Forum Stats
Member
Level 57
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:39:29 Reply

You would use the name attribute to get it with $_POST or $_GET.

If you had something like

<form action="file.php" method="post">
<input type="hidden" name="data" value="stuff"/>
<input type="submit" value="Submit"/>
</form>

On file.php you would use

$variable = $_POST['data'];

Or you could use $_GET as well if you make the method get. The value attribute is what you wnat the variable to have in it, such as if you did

echo $variable;

It would return

stuff


twitter | last.fm // Currently working on HarryJarry.com

BBS Signature
rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 19:40:16 Reply

thanks man

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 21:01:31 Reply

now im having another problem, when a user types in something from the input type=hiddens, only one word is shown.

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-05 21:07:44 Reply

how do I get it so that what they type is transferred to "word"+"word"+"word" etc.

Pilot-Doofy
Pilot-Doofy
  • Member since: Sep. 13, 2003
  • Offline.
Forum Stats
Member
Level 37
Musician
Response to a php question, i think its simple 2006-11-05 21:21:47 Reply

At 11/5/06 09:07 PM, rmbrstrongbad18 wrote: how do I get it so that what they type is transferred to "word"+"word"+"word" etc.

Are they in 3 separate fields? If so, do something like this:

echo $_GET['field1'] . $_GET['field2'] . $_GET['field3'];

If only one word is appearing when multiple words are typed in the same field, I'd have to see the page to diaginos it.

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-06 14:35:48 Reply

the method is POST, actually.

Go here, take a survey, and then when you copy the code and paste it somewhere, you'll see that only one word of your question appears.

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-06 14:39:40 Reply

you might actually want to make a survey first, because the survey there's question is already only one word.

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-06 15:37:32 Reply

I fixed that problem, but now the answers for questions 3, 4, and 5 won't show up and I don't know why

harryjarry
harryjarry
  • Member since: May. 15, 2005
  • Offline.
Forum Stats
Member
Level 57
Blank Slate
Response to a php question, i think its simple 2006-11-06 17:01:43 Reply

You have a few mistakes in your html.

- Fix the name in answer3 by putting a single quote at the beginning of the name attribute.
- Put answer4 for the name in andswer4, right now it doesn't have a name at all.
- Fix the name in answer5, put a single quote in from of answer5, you only have one at the beginning.

That should do the trick :).


twitter | last.fm // Currently working on HarryJarry.com

BBS Signature
rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-06 19:11:11 Reply

well like i said, i already fixed that part of the thing, and then i fixed the other part later so i dont need a lot of help anymore

rmbrstrongbad18
rmbrstrongbad18
  • Member since: Dec. 23, 2005
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to a php question, i think its simple 2006-11-06 20:56:28 Reply

to whoever used my site to spam and make it a redirection to another site, I took down the file that wrote up the link, and im working on fixing the problem. Please don't attempt to mess with my site.