Reputation: 11
I'm not really good with HTML, PHP, or other coding things. I really don't know how to make this work, but I made a submit form for my website. I did change the email already but I still get an error:
the 'domain' is currently unable to handle this request.
I got this code from here too and now I don't know what to do
THIS IS THE HTML FORM
<div class="container">
<form class="form-horizontal" role="form" method="post" action="share.php">
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name" value="">
</div>
</div>
<div class="form-group">
<label for="email" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="email" name="email" placeholder="[email protected]" value="">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="category">Category</label>
<div class="col-sm-10">
<select id="category" name="category" class="form-control">
<option value="">Student</option>
<option value="">Parent</option>
<option value="">School</option>
</select>
</div>
</div>
<div class="form-group">
<label for="message" class="col-sm-2 control-label">Message</label>
<div class="col-sm-10">
<textarea class="form-control" rows="4" name="message"></textarea>
</div>
</div>
<div class="form-group">
<label for="human" class="col-sm-2 control-label">2 + 3 = ?</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
</div>
</div>
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<! Will be used to display an alert to the user>
</div>
</div>
THIS IS THE PHP
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$category = $_POST['category'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$from = 'IKB FORM';
$to = 'EMAIL';
$subject = 'Importante Ka Ba User ';
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your name';
}
// Check if email has been entered and is valid
if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$errEmail = 'Please enter a valid email address';
}
if (!$_POST['category'] {
$errCategory = 'Please enter a valid email address';
}
//Check if message has been entered
if (!$_POST['message']) {
$errMessage = 'Please enter your message';
}
//Check if simple anti-bot test is correct
if ($human !== 5) {
$errHuman = 'Your anti-spam is incorrect';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errCategory && !$errMessage && !$errHuman) {
if (mail ($to, $subject, $body, $from)) {
$result='<div class="alert alert-success">Thank You! I will be in touch</div>';
} else {
$result='<div class="alert alert-danger">Sorry there was an error sending your message. Please try again later</div>';
}
}
}
?>
Upvotes: 1
Views: 2875
Reputation: 2294
You forgot a closing parentheses )
in the following if statement:
if (!$_POST['category'] {
change it to
if (!$_POST['category']) {
If you have problems with scripts in the future make sure you enable error reporting. These error reports will provide a lot of information on what has happened and make debugging a lot easier. This answer explains how you can enable it.
Upvotes: 5