Copy link to clipboard
Copied
I have a form and a mailscript I built with a tutorial. I do want to understand this as I go along as I will be needing this simple form with no verification soon.
Here is the form.
My form:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Page Title</title>
</head>
<body>
<div id="FormDiv" >
<form action="mailscript.php" method="post" name="ContactForm" id="ContactForm">
<table align="center">
<tbody>
<tr>
<td><label for="Subject">Subject:</label>
<br>
<input name="Subject" type="text" id="Subject" form="ContactForm" />
</td>
</tr>
<tr>
<td><label for="Message">Message:</label><br>
<textarea name="Message" cols="45" rows="5" id="Message" form="ContactForm"></textarea>
</td>
</tr>
<tr>
<td>
<label>
<input type="radio" name="RadioGroup1" value="11" id="RadioGroup1_1">
R1op1</label>
<br>
<label>
<input type="radio" name="RadioGroup1" value="12" id="RadioGroup1_2">
R1op2</label>
<br>
<label>
<input type="radio" name="RadioGroup1" value="13" id="RadioGroup1_3">
R1op3
</label>
</td>
</tr>
<tr>
<td>
<label>
<input type="radio" name="RadioGroup2" value="R2_1" id="RadioGroup2_1">
R2op1</label>
<br>
<label>
<input type="radio" name="RadioGroup2" value="R2_2" id="RadioGroup2_2">
R2op2</label>
<br>
<label>
<input type="radio" name="RadioGroup2" value="R2_3" id="RadioGroup2_3">
R2op3
</label>
</td>
</tr>
<td><input name="SubmitButton" type="submit" id="Submit Button" form="ContactForm" value="Send Message" /> </td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
Close my form.
This mailscript sends the subject and message only and it works as long as I don't use a Gmail or similar. Found this out thanks to this forum.
My Script:
<?php
$from="noreply@anydomain.com";
$email="info@anydomain.com";
$subject=$_POST['Subject'];
$message=$_POST['Message'];
mail ( $email, $subject, $message, "From:".$from );
Print "your message has been sent";
?>
Close my script.
My problem comes when I try to add the two radio groups to the email sent by the process. I have tried several options including commas, and even a plus sign which did not set any alarms in dreamweaver, some made to the inbox, some never did. Here is one example of my several attempts.
My script:
<?php
$from="noreply@anydomain.com";
$email="info@anydomain.com";
$subject=$_POST['Subject'];
$message=$_POST['Message']['RadioGroup1']['RadioGroup2'];
mail ( $email, $subject, $message, "From:".$from );
Print "your message has been sent";
?>
Close my script.
Two of the other variations I have tried:
$message=$_POST['Message''RadioGroup1''RadioGroup2']; Which raised a red flag for code.
$message=$_POST['Message'+'RadioGroup1'+'RadioGroup2']; (which sent mail but only a single "I" in the message field.
Other attempts at variations gave other non results. Thanks in advance, hopefully I am close, I do want to understand this as I go along and have put many hours in before I came here, thanks for your patience. Scott
In your processing script, change. . .
$message=$_POST['Message']['RadioGroup1']['RadioGroup2'];
. . .to . . .
$message=$_POST['Message']." : ".$_POST['RadioGroup1']." : ".$_POST['RadioGroup2'];
Explanation: $_POST is an array. The way you were trying to add them together is the way you would do it if it was a multilevel array, which is not what you have.
Note that I placed a pair of periods between each array item and put a colon between quotes within each. You could chain the variables using just a
...Copy link to clipboard
Copied
In your processing script, change. . .
$message=$_POST['Message']['RadioGroup1']['RadioGroup2'];
. . .to . . .
$message=$_POST['Message']." : ".$_POST['RadioGroup1']." : ".$_POST['RadioGroup2'];
Explanation: $_POST is an array. The way you were trying to add them together is the way you would do it if it was a multilevel array, which is not what you have.
Note that I placed a pair of periods between each array item and put a colon between quotes within each. You could chain the variables using just a single period, but there would be no space between them.
You really really need to read some intro material on PHP. Try PHP SOLUTIONS by Powers.
Copy link to clipboard
Copied
Thank you very much Rob, that worked great. And I am reading a lot but very confused on how to go about learning... there is so much and I am trying to get a form up and running at the same time.
Scott