Create an online contact form for Niagara University’s Admission Office using an
ID: 3709844 • Letter: C
Question
Create an online contact form for Niagara University’s Admission Office using an HTML document with the following textboxes: first, last, street address, city, state, zip, phone, email, and intended major. Two drop-down boxes, year (2018, 2019, 2020, 2021) and semester (spring, summer, and fall) plan to enter must also appear on the contact form. Once the user submits the contact for, an email is sent to your email account and to vdevine@niagara.edu. Do not include my email address when testing. Be sure to include all information on the contact form in the body of the email. The subject of the email is “Niagara University - Inquiry Form” and the email should like it was sent from the person contacting Niagara University. I JUST NEED THE CODE FOR THE EMAIL TO SEND AFTER HITTING THE SUBMIT BUTTON. IN PHP FORMAT PLEASE!!!
Explanation / Answer
<html>
<head>
<title>
Email Sender
</title>
</head>
<body>
<?php
if(isset($_REQUEST['email']) and $_REQUEST['email'] != "")
{
$address = trim($_REQUEST['email']);
$subject = "Niagara University - Inquiry Form";
$body = "First Name: " . $_REQUEST['fname'];
$body .= "Last Name: " . $_REQUEST['lname'];
$body .= "Address: " . $_REQUEST['street_add'];
$body .= "City: " .$_REQUEST['city'];
$body .= "State: " . $_REQUEST['state'];
$body .= "Zip: " . $_REQUEST['zip'];
$body .= "Phone: " . $_REQUEST['phone'];
$body .= "Email: " . $_REQUEST['email'];
body .= "Major: " . $_REQUEST['major'];
$body .= "Year: " . $_REQUEST['year'];
$body .= "Semester: " . $_REQUEST['semester'];
if(mail($address, $subject, $body))
echo "Mail sent successfully to: " . $_REQUEST['email'];
else
echo "Error sending mail. Please check main configuration in php.ini";
}
?>
<br><br>
<form method="post">
First Name: <input type="text" name="fname"><br>
Last Name: <input type="text" name="lname"><b>
Address: <input type="text" name="street_add"><br>
City: <input type="text" name="city"><br>
State: <input type="text" name="state"><br>
Zip: <input type="text" name="zip"><br>
Phone: <input type="text" name="phone"><br>
Email: <input type="text" name="email"><br>
Major: <input type="text" name="major"><br>
Year: <select name="year"><br>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
</select>
Semester: <select name="semester"><br>
<option value="spring">Spring</option>
<option value="summer">Summer</option>
<option value="fall">Fall</option>
</select>
<br><br>
<input type="submit" value="Submit">
<input type="reset" Value="Reset"
</form>
</body>
</html>
Please note that in order to php mail() function to work you have to add SMTP settings in php.ini file. I.e add SMTP port, email address and password of email account from which mail box mail will be sent.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.