Okay so my website is setup like /index.php?page=PAGE
.
I have a form on my contact page, but when I submit the POST form it strips the URL to /index.php
?
Why is that? I haven't touched PHP in months, but I don't remember this ever being an issue.
Here is my code:
<form action="" method="POST">
<?php
if (isset($_POST['contactBtn'])) {
$errors = array();
$name = $_POST['ContactInputName'];
$email = $_POST['ContactInputEmail'];
$message = $_POST['ContactInputMessage'];
if(empty($name)) {
$errors[] = 'You did not enter a name.';
}
if(empty($email)) {
$errors[] = 'You did not enter an email.';
}
if(empty($message)) {
$errors[] = 'You did not enter a message.';
}
if(strlen($message) < 4 || strlen($message) > 4096) {
$errors[] = 'Message length must be between 4 and 4096 characters long.';
}
if(empty($errors)) {
$Database->selectPrepare("INSERT INTO `contact` (`ID` ,`name` ,`email` ,`message` ,`time`, `IP`) VALUES (NULL , :name, :email, :message, :time, :IP);",
array(':name' => $name, ':email' => $email, ':message' => $message, ':time' => time(), ':IP' => $_SERVER["HTTP_CF_CONNECTING_IP"]));
echo ' <div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4>Success!</h4>
Your message has been recieved and we will get back to you as soon as possible!
</div>';
} else {
echo '
<div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4>ERROR!</h4>';
foreach($errors as $error) {
echo ' <p>'.$error.'</p>';
}
echo '</div>';
}
}
?>
<div class="form-group">
<label for="ContactInputName">Name</label>
<input type="text" class="form-control" id="ContactInputName" placeholder="John Smith">
</div>
<div class="form-group">
<label for="ContactInputEmail">Email address</label>
<input type="email" class="form-control" id="ContactInputEmail" placeholder="John@smith.com">
</div>
<div class="form-group">
<label for="ContactInputMessage">Message</label>
<textarea class="form-control" id="ContactInputMessage" rows="4"></textarea>
</div>
<button type="submit" id="contactBtn" class="btn btn-ar btn-primary">Submit</button>
</form>