Jump to content


Photo

Sending 2 values via a form


  • Please log in to reply
1 reply to this topic

#1 pmorrison

pmorrison
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 19 March 2006 - 05:30 PM

Hi,

I am trying to create an option to vote on a subject. I have created a form
like so:
<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>
However, I also want to send the value of the title of the article from the
form. I added a new input
<input type="hidden" name="article" value=$_GET['title']>
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:
<?php
include ("phpFunctions.inc");
$title = $_GET['title'];
echo("<title>Article: $type</title>");
?>
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

#2 Spixxx

Spixxx
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 07:14 PM

Here's what happened

Instead of

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

You supposed to use

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


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...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users