Hey there,
I'm using vB 5.4.0.
I've got a little problem and it'd be great if someone could give me a nudge in the right direction.
I want to create a form for users to fill out which will be sent to my email box.
I added the code inside a HTML module and it works perfectly. I receive the email and all is well.
BUT I need to know the username of the person who filled out the form. I've tried a lot of things (including somehow using a PHP module - which doesn't work because of Java) but nothing has worked so far.
Any idea is welcome!
Thanks in advance!
This is the code of the form:
And the code of the formmail.php
I'm using vB 5.4.0.
I've got a little problem and it'd be great if someone could give me a nudge in the right direction.
I want to create a form for users to fill out which will be sent to my email box.
I added the code inside a HTML module and it works perfectly. I receive the email and all is well.
BUT I need to know the username of the person who filled out the form. I've tried a lot of things (including somehow using a PHP module - which doesn't work because of Java) but nothing has worked so far.
Any idea is welcome!
Thanks in advance!
This is the code of the form:
Code:
<html> <head> <script language="Javascript"> <!-- Start function update_choice() { var categorychoice = document.forms.emailform.category; var subcategorychoice = document.forms.emailform.subcategory; subcategorychoice.options.length = 0; if (categorychoice.options[categorychoice.selectedIndex].value == "Option1") { subcategorychoice.options[1] = new Option("Sub-option 1"); subcategorychoice.options[2] = new Option("Sub-option 2"); subcategorychoice.options[3] = new Option("Sub-option 3"); subcategorychoice.options[4] = new Option("Sub-option 4"); } else if (categorychoice.options[categorychoice.selectedIndex].value == "Option2") { subcategorychoice.options[1] = new Option("Sub-option 1"); subcategorychoice.options[2] = new Option("Sub-option 2"); subcategorychoice.options[3] = new Option("Sub-option 3"); subcategorychoice.options[4] = new Option("Sub-option 4"); } } // End --> </script> </head> <body> <form name="emailform" action="formmail.php" target="_self" method="post"> <input type="hidden" name="access" value="irregeheim"> <select size="1" name="category" required onChange="update_choice()"> <option value="" selected></option> <option value="Option1">Option 1</option> <option value="Option2">Option 2</option> </select> <br> <br> <select size="1" required name="subcategory"> <option value="" selected></option> </select> <br><br> <input type="text" placeholder="Name" id="name" required name="name"> <button type="submit">SEND</button> </form> </body> </html>
PHP Code:
<?php
$recipient = "[email protected]";
$fmtResponse= implode("", file("../../response.php"));
$fmtMail= implode("", file("mail.htt"));
foreach($_POST as $key=> $val) {
$fmtResponse= str_replace("<$key>", $val, $fmtResponse);
$fmtMail= str_replace("<$key>", $val, $fmtMail);
}
if ($_POST["access"] == "irregeheim") {
mail($recipient, $_POST["subject"], $fmtMail);
}
echo $fmtResponse;
?>
Comment