Why am I unable to enter data in to db?
<?php include ( './includes/header.php' );
$error = "";
if (@$_POST['send']) {
$name = mysql_real_escape_string(strip_tags($_POST['name']));
$email = mysql_real_escape_string(strip_tags($_POST['email']));
$message = mysql_real_escape_string(strip_tags($_POST['message']));
if ($name == "") {
$error = "Name cannot be left empty.";
}
else if ($email == "") {
$error = "Enter valid email id";
}
else if ($message == "") {
$error = "Message cannot be left empty.";
}
else{
//send message
$sendmessage = mysql_query("INSERT INTO contact VALUES('','$name','$email','$message')",$db1) or die(mysql_error());
$error = "Message sent!!";
}
}
?>
<meta property="og:title" content="Contact Us" />
<meta property="og:description" content="For any help, drop us a mail" />
<meta property="og:image" content="http://studyfoyer.org/images/contactus.jpg" />
<title>Contact Us</title>
</head>
<?php include('includes/navigation.php');?>
<div class="container">
<div class="row">
<form class="log-page" action="contact.php" method="POST">
<h2 class="form-signin-heading">Get in touch</h2>
<div class="input-prepend">
<label for="InputUsername">Name</label>
<input type="text" class="form-control" name='name' placeholder="Name" required autofocus>
</div>
<div class="input-prepend">
<label for="InputEmail">Email</label>
<input type="email" class="form-control" name='email' placeholder="Email address" required>
</div>
<div class="input-prepend">
<label for="InputMessage">Message</label>
<textarea class="form-control" rows="3" name="message" placeholder="Your message" required></textarea>
</div>
<div class="controls form-inline">
<button class="btn btn-primary" name='send' type="submit">Send</button>
</div>
<?php echo $error; ?>
</div>
</form>
</div>
</div>
Db connection is done through header.php I've two websites(both on localhost) using same db, for contact info. can this affect? As the code seems to run fine on other one.