PDA

View Full Version : Php form submit radio group


Antoakatoe
11-19-2012, 11:36 AM
Hi guys,

I'm new to this and also inexperienced so please excuse my mistakes.

I have set up a website and from the HTML end of things all is well. I have however a feedback page where I have a form with a few data variables. I think I have the php set up ok except for the radio group. I have no clue how to set up the code for the radio group please see images below.

HTML for radio group...
http://farm8.staticflickr.com/7136/8168215470_f8d1c11de7.jpg

Here are my current data variables and I want to add below the radio group code...
http://farm8.staticflickr.com/7265/8168215156_0d39060ea4.jpg

If some one could please help me with this I would be extremely grateful.. This has been driving me nuts.

Anthony

edbr
11-20-2012, 07:43 AM
$radio =$_POST['foodquality'];

and in your email add echo $radio;

Antoakatoe
11-20-2012, 08:40 PM
Hi edbr,

Thank you for taking the time to help me... I have added in your code but I am unsure of the echo bit. Below is the code I currently have.. I got this from various YouTube tutorials etc. so I really am a small fish in a big pond!.

I am thinking of entering in a second radio group i am assuming i do the following...

$radio =$_POST['name of new group'];

put this below..
New Label: $name of new group <br>

am i on the right track or completely lost? I really appreciate your help so far.

Anthony

<?php

/*Subject and Email Variables*/

$emailSubject = 'Feedback';
$webMaster = 'my email address';

/*Data Variables*/

$name = $_POST['name'];
$email = $_POST['email'];
$contacttel = $_POST['contacttel'];
$dateoforder = $_POST['dateoforder'];
$time = $_POST['time'];
$avgtime = $_POST['avgtime'];
$shopselect = $_POST['shopselect'];
$radio =$_POST['foodquality']; <---------- YOUR Code

$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Contact Tel: $contacttel <br>
Date Of Order: $dateoforder <br>
Time: $time <br>
Average Wait Time: $avgtime <br>
Shop: $shopselect <br>
Food Quality: $foodquality <br> <--------------- Is this Correct?
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster,$emailSubject,$body,$headers);

/*Results rendered as HTML*/

$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3";URL=http://my url">
<style type="text/css">
<!--
body{
background-color:#111;
font-family: sans-serif, Veranda, Aerial, Helvetica;
font-size: 20px
font-style: normal;
line-height: normal;
color: #696969
text-decoration: none;
padding-top: 300px;
margin-left: 400px;
width: 450px;
}
-->
</style>
</head>
<div align="center">Your message has been sent, thank you.</div>
</body>
</html>
EOD;
echo "$theResults";
?>

edbr
11-21-2012, 01:32 AM
this is the section that will be sent to you and should contain the variables you have named $body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Contact Tel: $contacttel <br>
Date Of Order: $dateoforder <br>
Time: $time <br>
Average Wait Time: $avgtime <br>
Shop: $shopselect <br>
Food Quality: $foodquality <br> <--------------- Is this Correct?
EOD;

so last lline

Food Quality: $foodquality <br>

should be

Food Quality: $radio <br>

or change variable to $foodquality =$_POST['foodquality'];

Antoakatoe
11-21-2012, 06:44 PM
I will put the variable as this:

$foodquality =$_POST['foodquality'];

then the leave the data to be sent as this

Food Quality: $foodquality <br>

Hopefully I get it working. I'm due to upload to host on Monday. I will let you know if it all runs smoothly.

Really appreciate your help.

Anthony