I'm very, very new to PHP and I'm still trying to learn it. But I have a problem right now that I need to fix immediately so I am seeking any kind of help for it.
I'm trying to make a contact form which can send an message by emailing it.
Here is my html:
<form method="POST" action="?" >
<div id="header2">
<p id="heading">CONTACT ME</p>
<p> Send your inquiries or comments here and I'll get back to you right away.</p>
</div>
<label for="name">Your Name </label>
<input type="text" name="name" placeholder="Juan Dela Cruz" width="100px;">
<label for="email"> Email Address </label>
<input type="text" name="email" placeholder="yourname@email.com">
<label for="contact"> Contact Number </label>
<input type="text" name="contact" placeholder="Mobile or Landline">
<label for="message"> Message </label>
<textarea type="text" name="message" rows="10" cols="25" placeholder="Your Message"></textarea>
<input type="submit" value="Send Message" id="submit">
<input type="reset" value="Reset Fields" id="reset">
<p id="feedback"> <?php echo $feedback; ?> </p>
<div id="socialcontact">
<h4> CJSS </h4>
<p> Address
</p>
<a href="#"> <img src="images/fb-2.png" alt="Find me on Facebook"/> </a> <a href="#"> <img alt="Follow me on Twitter" src="images/twitter-2.png" /> <a href="#"> <img alt="Connect with me on Linked In" src="images/linkedin-2.png" /> <a href="#"> <img alt="Check me out on Behance" src="images/behance-2.png" />
</div>
</form>
Now here is my php:
<?php
$to = 'myemail@gmail.com';
$subject = 'An inquiry from your website';
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$body = $_POST['message'];
$message = <<<EMAIL
$name
$email
$contact
$message
EMAIL;
$header = "From: $email";
if($_POST){
if($name == '' || $email == '' || $message == ''){
$feedback = 'Kindly fill our all the (*)necessary fields';
}else{ mail($to, $subject, $body, $header);
$feedback = 'Thank you, email sent. I will get back to you as soon as I can.';}
}
?>
I put this php on top of everything.
When I preview it through my testing server, it shows error messages:
( ! ) Notice: Undefined index: email in C:\wamp\www\projectlevity4\contact.php on line 8 Call Stack
Time Memory Function Location
1 0.0007 258368 {main}( ) ..\contact.php:0
( ! ) Notice: Undefined index: contact in C:\wamp\www\projectlevity4\contact.php on line 9 Call Stack
Time Memory Function Location
1 0.0007 258368 {main}( ) ..\contact.php:0
( ! ) Notice: Undefined index: message in C:\wamp\www\projectlevity4\contact.php on line 10 Call Stack
Time Memory Function Location
1 0.0007 258368 {main}( ) ..\contact.php:0
( ! ) Notice: Undefined variable: message in C:\wamp\www\projectlevity4\contact.php on line 19 Call Stack
Time Memory Function Location
1 0.0007 258368 {main}( ) ..\contact.php:0
What should I do to fix this? I'm trying to beat a deadly deadline, I hope you can help me out.
Thanks
` – Sean Sep 06 '14 at 17:25