I've made a html using html, and it contains some radio buttons. How would I know which button is selected? I need to send the selected option to my email, but I don't quite understand how it would be incorporated into my php script. Thank you all so much!
Below is my php script:
<?php
$to = 'dinefour4@gmail.com';
$subject = 'The subject';
$name = $_POST['name'];
$email = $_POST['email'];
$option = $_POST['place']; <-- is this the way to know the selected button?
$mobile = $_POST['mobile'];
$message = <<<EMAIL
$name
$email
$mobile
EMAIL;
$header = '$email';
if($_POST) {
mail($to, $subject, $message, $header);
}
?>
<div id="signup">
<form action="signup.php" method="POST" onsubmit="return validate()">
<label name = "sutitle"> <font size="7"> sign up here!</font></label> <br/>
<label ><font size="5" >Name:</font>
<input type="text" name="name" required ></label><br />
<label ><font size="5">Mobile:</font>
<input type="text" name="mobile" required></label><br />
<label ><font size="5">Email: </font>
<input type="text" name="email" required></label><br />
<label> <font size="5">Where to meet your Friends?</font><br/>
<input type="radio" name="place" value="revelle" > <font size="5">Revelle </font><br>
<input type="radio" name="place" value="muir"> <font size="5">Muir </font><br>
<input type="radio" name="place" value="warren"> <font size="5">Warren </font><br>
<input type="radio" name="place" value="erc" > <font size="5">ERC </font><br>
<input type="radio" name="place" value="village"> <font size="5">The Village </font><br>
</label>
<input type="submit" value="Submit">
</form>
<?php
$to = 'dinefour4@gmail.com';
$subject = 'The subject';
$name = $_POST['name'];
$email = $_POST['email'];
$option = ""
if(isset($_POST['place']))
{
$option = $_POST['place'];
}
$mobile = $_POST['mobile'];
$message = <<<EMAIL
$name
$email
$mobile
EMAIL;
$header = '$email';
if($_POST) {
mail($to, $subject, $message, $header);
}
?>
<div id="signup">
<form action="signup.php" method="POST" onsubmit="return validate()">
<label name = "sutitle"> <font size="7"> sign up here!</font></label> <br/>
<label ><font size="5" >Name:</font>
<input type="text" name="name" required ></label><br />
<label ><font size="5">Mobile:</font>
<input type="text" name="mobile" required></label><br />
<label ><font size="5">Email: </font>
<input type="text" name="email" required></label><br />
<label> <font size="5">Where to meet your Friends?</font><br/>
<input type="radio" name="place" value="revelle" > <font size="5">Revelle </font><br>
<input type="radio" name="place" value="muir"> <font size="5">Muir </font><br>
<input type="radio" name="place" value="warren"> <font size="5">Warren </font><br>
<input type="radio" name="place" value="erc" > <font size="5">ERC </font><br>
<input type="radio" name="place" value="village"> <font size="5">The Village </font><br>
</label>
<input type="submit" value="Submit">
If the radio button is selected, then it will set in '$option' variable. Otherwise '$option' variable will be empty.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.