I have been doing this registration project in php, however whenever i access it on localhost (im using wampserver), its giving me this error
On home page of sign up (top view): ERROR: Notice: Undefined index: fname in
On home page of sign up (buttom view) ERROR: Notice: Undefined variable: feedback in
upon sending an email(which doesn't proceed due to error) ERROR: Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in
I am not really sure what when wrong since this is the first time i tried coding a php file that sends an email. I hope someone can help me out here
---here is the code i used(i based it on tutorials i see)
<?php
$to = "temblormariel@ymail.com";
$subject = 'SmoothTeamPH SignUp Registration';
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$pnum = $_POST['pnum'];
$shippingAdd = $_POST['shippingAdd'];
$body = <<<Email
Hi!
Smooth Team PH New Registration
First Name: $fname
Last Name: $lname
Email Address: $email
Phone Number: $pnum
Shipping Address: $shippingAdd
Thanks,
$lname, $fname
Email;
$header = "From: $email";
if($_POST){
if($lname == '' || $fname == '' || $email == '' || $pnum == '' || $shippingAdd == ''){
$feedback = 'Kindly fill out all the fields';
}else{
mail($to, $subject, $body, $header);
$feedback = "Thank you for providing your information. We will get back to you shortly";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Smooth Team PH Inc</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<div id="container">
<header id="header">
<div id="menu" class="menu">
<ul>
<li><a href="#" target="_blank"> HOME </a></li>
<li><a href="#" target="_blank"> SIGN UP </a></li>
<li><a href="#" target="_blank"> ABOUT US </a></li>
<li><a href="#" target="_blank"> CONTACT </a></li>
</ul>
</div>
</header>
<section id="content">
<h2>Sign Up</h2>
<div id="signup">
<form action="?" method="post">
<ul>
<li>
<label for="fname">First Name : </label>
<input type="text" name="fname" id="fname" />
</li>
<li>
<label for="lname">Last Name : </label>
<input type="text" name="lname" id="lname" />
</li>
<li>
<label for="email">Email : </label>
<input type="text" name="email" id="email" />
</li>
<li>
<label for="pnum"> Phone Number : </label>
<input type="text" name="pnum" id="pnum" />
</li>
<li>
<label for="shippingAdd">Shipping Address : </label>
<textarea id="shippingAdd" name="shippingAdd" cols="42" rows="9"></textarea>
</li>
<li>
<input type="submit" value="Submit">
</li>
</ul>
<p id="feedback"> <?php echo $feedback; ?> </p> <!-- will be transfered to 2nd page later -->
</form>
</div>
</section>
<footer id="footer">
<div id="fmenu" class="fmenu">
<p>©2015 smoothteamphinc | Design & Development by Mariel Temblor</p>
</footer>
</div>
</div>
</body>
</html>