I was recently asked by work to put together a contact form to email page on our site.
So fair enough I thought pretty easy, so I coded one in php. Only to findout when testing it that our site is on a windows server. And does not like PHP!!
So I am going to have to code it again now in .asp which I will say I have little experience in. Now I know I could easily google a script and download it.
But my problem comes when I will have to customise the code to my needs, i need someone to explain how I change the way the emailBody is output/formatted?
Because the actual form I have to come up with has to have multiple fields, with their values being displayed within the emailBody. And so far the examples I have seen online have been basic dealing simply with Name, Email and Message.
Below is a snippet of code from my original files if someone is willing to take a look to see how it needs outputting. You see i understand the concept of how the PHP file gets the info using id's and arrays.
But looking at asp it seems a bit general not sure how to define values.
<form method="post" name="myemailform" action="http://www.moneymedia.co.im/paform-to-email.php">
<label for='entrant-name'>Name: </label><br>
<input type="text" name="entrant-name" size="40">
<input type="text" name="entrant-company" size="40">
<label for='entrant-position'>Position: </label><br>
<input type="text" name="entrant-position" size="40">
<label for='entrant-email'>Contact Email:</label><br>
<input type="text" name="entrant-email" size="40">
<label for='entrant-phone'>Contact Telephone Number:</label><br>
<input type="text" name="entrant-phone" size="40">
<label for='nominee-name'>Name:</label> <br>
<input type="text" name="nominee-name" size="40">
<input type="text" name="nominee-company" size="40">
<label for='nominee-position'>Position: </label><br>
<input type="text" name="nominee-position" size="40">
<label for='values-message'>What values do you/your PA bring to your organisation?</label> <br>
<textarea name="values-message" cols="40" rows="5"></textarea>
<label for='why-message'>Why do you think you/your PA should win the PA of the Year Award?</label> <br>
<textarea name="why-message" cols="40" rows="5"></textarea>
<input type="submit" name='submit' value="submit">
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
$entrant_name = $_POST['entrant-name'];
$entrant_position = $_POST['entrant-position'];
$entrant_company = $_POST['entrant-company'];
$entrant_email = $_POST['entrant-email'];
$entrant_phone = $_POST['entrant-phone'];
$nominee_name = $_POST['nominee-name'];
$nominee_position = $_POST['nominee-position'];
$nominee_company = $_POST['nominee-company'];
$values_message = $_POST['values-message'];
$why_message = $_POST['why-message'];
echo "Name and email are mandatory!";
echo "Bad email value!";
$email_from = 'firstname.lastname@example.org';//<== update the email address
$email_subject = "PA of the Year Award - Application";
$email_body = "You have received a new message from $entrant_name, $entrant_position at $entrant_company.\n".
"You can contact me via email at: $entrant_email, or by phone on: $entrant_phone.\n".
"I $entrant_name, $entrant_position of $entrant_company. Wish to nominate my PA: $nominee_name for the PA of the Year Award.\n".
"What values does my PA bring to the organisation?\n $values_message\n".
"Why I think my PA should win the PA of the Year Award?\n $why_message\n".
"Nominee Contact Details:\n".
$to = "email@example.com";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $entrant_email \r\n";
//Send the email!
//done. redirect to thank-you page.
// Function to validate against any email injection attempts
$injections = array('(\n+)',
$inject = join('|', $injections);
$inject = "/$inject/i";