Hello guys,
I was just wondering what I was doing wrong here, I’ve ‘created’ a website form in PHP but when I click my submit button it doesn’t seem to fetch:
php.php?s=1
or
php.php?s=2
which is then used to print either Success or Failure.
Here’s my code:
<html>
<head>
<title></title>
<meta charset="utf-8" />
<link rel="stylesheet" href="footer.css" type="text/css"/>
<link rel="stylesheet" href="header.css" type="text/css"/>
<link rel="stylesheet" href="php/phpbody.css" type="text/css"/>
</head>
<!--body-->
<body>
<div id="container">
<h3 id="h3">Contact Me:</h3>
<?php
$s = isset($_GET['s']) ? $_GET['s'] : '';
if ($s=="1") {
echo ('<span class="success">Success! Your enquiry has been sent.</span>');
}else if ($s=="2"){
echo ('<span class="fail">Sorry! Your enquiry has not been sent.
Please ensure you have filled in the form correctly.</span>');
}
?>
<h5 id="h5">To contact me, please use this form, created with PHP:</h5>
<form id="form1" name="form1" method="POST" action"php/send.php">
<strong>First Name:</strong><br><input type="text" name="firstname" id="firstname"><br><br>
<strong>Last Name:</strong><br><input type="text" name="lastname" id="lastname"><br><br>
<strong>E-mail:</strong><br><input type="text" name="email" id="email"><br><br>
<strong>Enquiry:</strong><br><textarea name="enquiry" id="enquiry" cols="45" rows="5"></textarea><br><br>
<strong>Security:</strong> 6 + 4 = <input type="text" name="security" id="security" size="1"><br><br>
<input type="submit" name="submit" id="submit" value="Submit"/>
</form>
</div>
<?php include('header.php'); ?>
<?php include('footer.php'); ?>
</body>
</html>
Send.php:
[php]
<?php $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $enquiry = $_POST['enquiry']; $security = $_POST['security']; $to = "[email protected]"; $subject= "New Form Enquiry"; $message = "A potential employer has submitted an enquiry from your website:\n\n First Name: $firstname\n\n Last Name: $lastname\n\n Email: $email \n\n Enquiry: $enquiry\n\n You should probably respond."; if($security = "10"){ mail($to,$subject,$message); header("Location:php.php?s=1"); //php.php being the forms location }else{ header("Location:php.php?s=2"); //php.php being the forms location } ?>[/php]
Any ideas would be much appreciated.
Thanks.