hi, i am trying to learn web development using tutorials, i have this contact form my problem is that if i put the php on a separate file n call it it works fine but when i put on same page it gives Notice: Undefined index...
what do i do or wat am i doing wrong. i want the echo to be displayed on same page....
plz help
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Contact Us</title>
<!--[if lt IE 9]>
<![endif]-->
<link rel="stylesheet" media="all" href="css/style.css"/>
<link rel="stylesheet" href="flexslider.css" type="text/css" media="screen" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="jquery.flexslider-min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!-- Adding "maximum-scale=1" fixes the Mobile Safari auto-zoom bug: http://filamentgroup.com/examples/iosScaleBug/ -->
<style type="text/css">
body {
background:url(images/background.jpg) #19191A no-repeat left top;
background-size: 100%;
}
</style>
</head>
<?php include('includes/header.php'); ?>
<?php include('includes/nav.php'); ?>
<body>
<div class="wrap_container">
<div class="main">
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: Demo';
$to = 'info@domain.com';
$subject = 'Hello';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit'] && $human == '4') {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '4') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>
<form method="post" action="contact.php">
<label span class="cursive">Name</label>
<input name="name" placeholder="Type Here">
<label span class="cursive">Email</label>
<input name="email" type="email" placeholder="Type Here">
<label span class="cursive">Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<label span class="cursive">*What is 2+2? (Anti-spam)</label>
<input name="human" placeholder="Type Here">
<input id="submit" name="submit" type="submit" value="Submit" span class="cursive">
</form>
</section>
<footer class="body">
</footer>
</body>
</html>