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
help with php radio buttons!
Old 08-31-2010, 11:39 AM help with php radio buttons!
Novice Talker

Posts: 7
Name: seen
Trades: 0
Hi guys,

My first post here after reading some very helpful responses over the last few months.
I'm having trouble passing radio button values to a results page and wondered if anyone would be able to spot anything wrong with the following code?

Any ideas are very much appreciated as this is the first time I've used PHP forms with radio buttons...

Here's the code section for the form page:
--------
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$interest = $_POST['interest'];
$hear = $_POST['hear'];
$radioq1 = $_POST['radioq1'];
$radioq2 = $_POST['radioq2'];
$radioq3 = $_POST['radioq3'];
$radioq4 = $_POST['radioq4'];
$radioq5 = $_POST['radioq5'];
$radioq6 = $_POST['radioq6'];
$radioq7 = $_POST['radioq7'];
$radioq8 = $_POST['radioq8'];
$radioq9 = $_POST['radioq9'];
$radioq10 = $_POST['radioq10'];
$score = 0;
}
--------
These are the NAMES for the form entries which then get POSTed to another page that just processes:

<?php

$points = $_POST['$score + $radioq1 + $radioq2 + $radioq3 + $radioq4 + $radioq5 + $radioq6 + $radioq7 + $radioq8 + $radioq9 + $radioq10'];

if ($points > 15) {
header('location: results-page.php?id=4');
} else if ($points > 11) {
header('location: results-page.php?id=3');
} else if ($points > 5) {
header('location: results-page.php?id=2');
} else {
header('location: results-page.php?id=1');
}
?>

The final page just shows the page and draws text and images from a database so simple stuff. The only thing is I can't get the values to add up! The result is always the same: results-page?id=1

Iknow it's something simple but my head hurts!!!
koldhands is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-31-2010, 01:03 PM Re: help with php radio buttons!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
1/ Radio buttons should ALL have the same name as only ONE from any group should be selectable.

2/ If you want multiple selections use checkboxes!

3/ Only radio buttons or checkboxes that ARE selected or checked return a value.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 09-03-2010, 07:29 AM Re: help with php radio buttons!
Novice Talker

Posts: 7
Name: seen
Trades: 0
Thanks for the reply,

I've actually got a form that has 12 questions each with a set of 2 or 3 radio buttons.

Here's the code from one of the questions:

<td><input type="radio" name="radioq8" value="0" />&nbsp;15 minutes or less</td>
<td><input type="radio" name="radioq8" value="1" />&nbsp;15 minutes to 45 minutes</td>
<td><input type="radio" name="radioq8" value="2" />&nbsp;45 minutes +</td>

So when I POST radioq8 to the next page I should be able to ECHO the value but I am getting nothing??
koldhands is offline
Reply With Quote
View Public Profile
 
Old 09-04-2010, 07:55 AM Re: help with php radio buttons!
Novice Talker

Posts: 12
Name: chris
Trades: 0
Your post collection variables $somevar = $_POST['somename']; need to be on the page that needs to collect and "manage" the information if the form is being submitted to the same page the form is on then the post vars are fine where they are otherwise move them into the correct page

second issue is the if(isset($_POST['submit']))

is this the name of the submit button? IE name='submit' if not correct this

Last edited by cdjhosting; 09-04-2010 at 07:57 AM..
cdjhosting is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help with php radio buttons!
 

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