Jump to content

Archived

This topic is now archived and is closed to further replies.

pmorrison

Sending 2 values via a form

Recommended Posts

Hi,

I am trying to create an option to vote on a subject. I have created a form
like so:
[code]
<form method="get" action="place_vote.php">
<b>
Please place your vote for this article<p>
<input type="radio" name="vote" value="1"> 1    Worst
<br />
<input type="radio" name="vote" value="2"> 2
<br />
<input type="radio" name="vote" value="3"> 3
<br />
<input type="radio" name="vote" value="4"> 4
<br />
<input type="radio" name="vote" value="5"> 5    Best
<br />
<br />
<input type="submit" value="Vote">
</b>
</form>
[/code]
However, I also want to send the value of the title of the article from the
form. I added a new input
[code]
<input type="hidden" name="article" value=$_GET['title']>
[/code]
but using the title like this done not work. I know that this GET call does
work because further up in the code I do the following and it works fine:
[code]
<?php
include ("phpFunctions.inc");
$title = $_GET['title'];
echo("<title>Article: $type</title>");
?>
[/code]
The problem is that it sends article=%24title rather than the correct title.
I dont know why this wont work, so any help would be much appreciated!

Cheers,

Paul

Share this post


Link to post
Share on other sites
Here's what happened

Instead of

[code]
<?php
include ("phpFunctions.inc");
$title = $_GET['title'];
echo("<title>Article: $type</title>");
?>
[/code]

You supposed to use

[code]
<?php
include ("phpFunctions.inc");
$title = $_POST['title'];
echo("<title>Article: $type</title>");
?>
[/code]


Because the hidden field grabbed the GET variable of title, and has it...that part works. But when you submit the form, it uses get, but instead since there are no GET variables in the voting table, just use POST.

Try that, and if not try using method="post" in your form

Hope it helps...

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.