Hi I need to do a form with radio buttons and the user selects one option. When an option is selected and submit button is pressed the answer needs to be sent to a specific email. How can I do that? Please help me its quite urgent
Here is my HTML and javascript code of what I did till now.
this code in the main page related to how to launch the popup page when page loads:
You get the data from the radio buttons the same way you would get any data from a form. However, your script is insecure.
Your form may use a radio button, but there is nothing in that script that stops someone from submitting information from an altered form using a text field or using a bot to post to your page. That would enable them to alter your message using mail injection.
For yes/no or other exclusive choice situations using radio buttons, translate the values using an array of acceptable answers. This way the actual user input never reaches your mail message, database or whatever else you might be using to store or convey information.
For example, instead of using “yes” and “no” in the value attribute of a radio button for a yes/no answer to a question, use 1 and 0. Then construct an array like this
$answers('No','Yes');
$ynanswer = $answers[$_POST['yn']];
if(empty($ynanswer))
{
$ynanswer = 'No';//default to no if input was not what was expected
}
Also sending mail with PHP is somewhat of dark art, especially due to spam filters. It isn’t enough to just use the mail function by itself anymore. You may need to send additional headers in order to get the mail to go through.
I would really recommend using a pre-written mail class such as PHPMailer for sending the mail instead.