Jump to content

Sending 2 values via a form


pmorrison

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
Link to comment
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...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.