I had coded html and php but cloudsblack84#gmail.com(mail address) still cannot receive mail form my website ( http://cloudsblack.info/ ) and at the end when I clicked the submit button will go into blank page (http://cloudsblack.info/index.php) . Sorry I am just beginner on web design need to learn a lot from you guys .
HTML PART
<!-- Contact Section -->
<section id="contact" class="contacts-section">
<div class="container content-lg">
<div class="title-v1">
<h2>Contact Us</h2>
<p>I'm always happy to hear from you. Please contact or email me for appointment or service enquiry.</p>
</div>
<div class="row contacts-in">
<div class="col-md-6 md-margin-bottom-40">
<ul class="list-unstyled">
<li><i class="fa fa-home"></i> Kuala Lumpur</li>
<li><i class="fa fa-phone"></i> (6)016-7187764</li>
<li><i class="fa fa-envelope"></i> -removed-email-</li>
</ul>
</div>
<div class="col-md-6">
<form method="post" action="index.php">
<label>Name</label>
<div class="row margin-bottom-20">
<div class="col-md-7 col-md-offset-0">
<input type="text" name="name" class="form-control">
</div>
</div>
<label>Email<span class="color-red">*</span></label>
<div class="row margin-bottom-20">
<div class="col-md-7 col-md-offset-0">
<input type="text" name="email" class="form-control">
</div>
</div>
<label>City</label>
<div class="row margin-bottom-20">
<div class="col-md-7 col-md-offset-0">
<input type="text" name="city" class="form-control">
</div>
</div>
<label>Telephone</label>
<div class="row margin-bottom-20">
<div class="col-md-7 col-md-offset-0">
<input type="text" name="telephone" class="form-control">
</div>
</div>
<label>Interested</label>
<div class="row margin-bottom-20">
<div class="col-md-7 col-md-offset-0">
<input type="text" name="interested" class="form-control">
</div>
</div>
<label>Message</label>
<div class="row margin-bottom-20">
<div class="col-md-11 col-md-offset-0">
<textarea rows="8" name="message" class="form-control"></textarea>
</div>
</div>
<p><button type="submit" name="submit" class="btn-u btn-brd btn-brd-hover btn-u-dark">Send Message</button></p>
</form>
</div>
</div>
</div>
PHP PART
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$city = $_POST['city'];
$telephone = $_POST['telephone'];
$interested = $_POST['interested'];
$message = $_POST['message'];
$submit = $_POST['submit'];
if($submit){
$from = 'From: -removed-domain-'."\r\n";
$to = '-removed-email-';
$subject = "Message from -removed-domain-";
$body = "".
"From: ".$name."\n".
"E-mail: ".$email."\n".
"City: ".$city."\n".
"Telephone: ".$telephone."\n".
"Interested: ".$interested."\n".
"Message: ".$message."\n";
if(mail($to, $subject, $body, $from)){
echo '<p>Your message has been sent!</p>';
}
else{
die('<p>Something went wrong, go back and try again!</p>');
}
}
?>
If you see the message Something went wrong, go back and try again! your mail server is incorrectly configured within php.ini or it has timed-out
If you see Your message has been sent!, check your spam folder.
If all else fails, access your mail server logs through WHM or CPanel or contact your hosting provider
$submit = $_POST['submit'];
You havn't given the <button name='submit'> a value, if($submit){ is false/non-existent in your POST data.
Still not a reason for the blank page, need to look at your apache/php error logs or ask your hosting provider.
Related
I am finishing up a ONE-PAGE responsive website for a client. I am using a Bootstrap contact form at the bottom of the HTML page. There is a second Contact.php file to process the form. The PHP code is showing up in the contact form text fields.
I've read and followed the directions for other folks' similar problems, but my client's URL ends in .HTML so I don't want to make the URL end in .PHP to make the contact form work. Is there a workaround to A) get the code to NOT show up in the text fields, and B) process the form without changing the HTML to PHP. Thanks a bunch - this has been driving me nuts for two days now.
HTML DOC.
<!-- FORM SECTION STARTS HERE---- -->
<section id="contact">
<div class="container">
<div class="row">
<div class="col-md-12">
<h3 class="h3-complete-form">Just complete the form below.</h3>
</div>
</div>
</div>
<form class="form-horizontal" role="form" method="post" action="contact.php">
<div class="row">
<div class="col-sm-3"></div>
<div class="contact-icon">
<i class="fas fa-user"></i>
</div>
<div class="form-inline">
<div class="col-sm-2 form-group">
<label for="name" class="control-label">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="First & Last Name">
<?php
echo $errName;?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3"></div>
<div class="contact-icon">
<i class="fas fa-envelope"></i>
</div>
<div class="form-inline">
<div class="col-sm-2 form-group">
<label for="email" class="control-label">Email</label>
<input type="email" class="form-control" id="email" name="email" placeholder="example#domain.com">
<?php
echo $errEmail;?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3"></div>
<div class="contact-icon">
<i class="fas fa-pencil-alt"></i>
</div>
<div class="form-inline">
<div class="col-sm-10 form-group">
<label for="message" class="control-label">Message</label>
<textarea class="form-control" rows="4" name="message"
placeholder="How can I help you?">
<?php
echo $errMessage;?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3"></div>
<div class="contact-icon">
<i class="fas fa-pencil-alt"></i>
</div>
<div class="form-inline">
<div class="col-sm-10 form-group">
<label for="human" class="control-label">2 + 3 = ?</label>
<input type="text" class="form-control" id="human" name="human" placeholder="Your Answer">
<?php echo $errHuman";?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4"></div>
<div class="form-inline">
<div class="form-group">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary">
<?php echo $result; ?>
</div>
</div>
</div>
</div>
<!-- Displays an alert to user -->
<div class="row">
<div class="form-group">
<div class="col-sm-10 col-sm-offset-2">
<?php echo $result; ?>
</div>
</div>
</div>
</form>
</div>
</div>
<!-- --------- SECTION 8: CONTACT ME ENDS HERE------ -->
PHP DOC
<?php include 'validate.php'; ?>
<?php
if (isset($_POST["submit"])) {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$human = intval($_POST['human']);
$from = "From: ". $name . " <" . $email . ">\r\n";
$to = 'myname#myemailaddress.com';
$subject = 'Message from Contact Form';
$body ="From: $name\n E-Mail: $email\n Message:\n $message";
// Check if name has been entered
if (!$_POST['name']) {
$errName = 'Please enter your first and last 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';
}
//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 answer is incorrect';
}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$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>';
}
}
}
?>
You can try with .htaccess file to treat .html extension as .php.
RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]
I want to get an email from an html form. I was following a tutorial that used PHP, which I have never used before, and it doesn't seem to work. After I hit submit, the php page opens, but an email is not sent to me. Can someone please help me.
HTML(A couple inputs like name and email, etc. and a submit button at the bottom):
<form action="contact_form_process.php" method="POST">
<section id="contact" class="py-3">
<div class="container">
<div class="row">
<div class="col-md-9 mx-auto">
<div class="card p-4">
<div class="card-body">
<h3 class="text-center lato-font">Please Fill Out This Form To Contact Us</h3>
<hr>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input id="first_name" type="text" class="form-control" placeholder="First Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input id="last_name" type="text" class="form-control" placeholder="Last Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input id="email" type="text" class="form-control" placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input id="phone_num" type="text" class="form-control" placeholder="Phone Number">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<textarea class="form-control" name="" id="message" rows="10" placeholder="Message"></textarea>
</div>
</div>
</div>
</div>
<div class="card-footer">
<input type="submit" class="btn btn-outline-success btn-block" value="Send">
<button type="submit" class="btn btn-outline-success btn-block">Send</button>
</div>
</div>
</div>
</div>
</div>
</section>
</form>
Here is my PHP:
<?php
// Subject and Email Variables
$emailSubject = 'Test Email';
$webMaster = 'tamiroffen#gmail.com';
// Gathering Data Variables
$first_nameField = $_POST['first_name'];
$last_nameField = $_POST['last_name'];
$emailField = $_POST['email'];
$phone_numField = $_POST['phone_num'];
$messageField = $_POST['message'];
$body = <<<EOD
<br><hr><br>
Email: $emailField <br>
Name: $first_nameField <br>
Phone Number: $phone_numField <br>
Message: $message <br>
EOD;
$headers = "From: $emailField\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
?>
Thank you!
mail() needs to be enabled as #esqew points out in his comment - this would look something like this (this is on my BigRock environment YMMV) -
ini_set("include_path", '<path to php>' . ini_get("include_path") );
require_once "Mail.php";
Also, if you are using GMail, you also need to set up GMail to allow sending mail through SMTP - https://support.google.com/mail/answer/7126229?visit_id=636741342414654323-2069917091&hl=en&rd=1
$webMaster = 'tamiroffen#gmail.com';
I assume this is the address where the emails are sent to. From what I've heard, PHP mail() function doesn't work for gmail(if it's on the receiver end).
You can just use another email provider like hotmail or any and forward emails from it to your gmail
Watch this video if you need more info on it, How to create a PHP Contact Form Tutorial
I have a form in Bootstrap that's inside a modal. When I click the "Submit"
there is seems nothing happen,
I have checked the code for the typo and other errors and it seems nothing wrong with my php code but again every time I fill the form and hit the submit button the page is reloaded but email/data not posted
here is the complete php code :
<?php
if(isset($_POST['Submit'])){
$to = 'Support#example.com'; // this is your Email address
$from = $_POST['faq-contact-email'];// this is the sender's Email address
$first_name = $_POST['faq-contact-firstname'];
$last_name = $_POST['faq-contact-lastname'];
$division = $_POST['faq-contact-subject'];
$subject = $_POST['contact-subject'];
$themessage = $_POST['faq-contact-msg'];
$message = 'Support mail from : '.$first_name.' '.$last_name.'<br/>
To : '.$division.' Division<br/>
<hr/>
'.$themessage.'';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: ".$from."\r\n"."X-Mailer: php";
mail($to,$subject,$message,$headers);
echo "Support message Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>
<div class="content">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#faq4" href="#faq4_q1"><i class="fa fa-envelope-o"></i> Contact Support</a>
</h3>
</div>
<div id="faq4_q1" class="panel-collapse collapse in">
<div class="panel-body">
<form method="post" action="" class="form-horizontal push-10-t" >
<div class="form-group">
<div class="col-xs-6 col-sm-4">
<div class="form-material form-material-primary">
<input class="form-control" type="text" id="faq-contact-firstname" name="faq-contact-firstname" placeholder="Enter your firstname..">
<label for="faq-contact-firstname">Firstname</label>
</div>
</div>
<div class="col-xs-6 col-sm-4">
<div class="form-material form-material-primary">
<input class="form-control" type="text" id="faq-contact-lastname" name="faq-contact-lastname" placeholder="Enter your lastname..">
<label for="faq-contact-lastname">Lastname</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-8">
<div class="form-material form-material-primary input-group">
<input class="form-control" type="email" id="faq-contact-email" name="faq-contact-email" placeholder="Enter your email..">
<label for="faq-contact-email">Email</label>
<span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-4">
<div class="form-material form-material-primary">
<select class="form-control" id="faq-contact-subject" name="faq-contact-subject" size="1">
<option value="1">Tech Support</option>
<option value="2">Billing</option>
</select>
<label for="faq-contact-subject">Where?</label>
</div>
</div>
</div>
<div class="col-xs-6 col-sm-4">
<div class="form-material form-material-primary">
<input class="form-control" type="text" id="contact-subject" name="contact-subject" placeholder="Enter your subject..">
<label for="contact-subject">Subject</label>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material form-material-primary">
<textarea class="form-control" id="faq-contact-msg" name="faq-contact-msg" rows="7" placeholder="Enter your message.."></textarea>
<label for="faq-contact-msg">Message</label>
</div>
<div class="help-block text-right">Feel free to use common tags: <blockquote>, <strong>, <em></div>
</div>
</div>
<div class="form-group remove-margin-b">
<div class="col-xs-12">
<button class="btn btn-sm btn-primary" name="submit" type="submit"><i class="fa fa-send push-5-r"></i> Send Message</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
Can anyone please help me what's wrong with my code
If someone could help that would be greatly appreciated!
Thanks
Ok, I make an answer of my comment.
if(isset($_POST['Submit']))
Change Submit to submit. You can also use
if(isset($_POST))
instead
Check your first line
if(isset($_POST['Submit']))
You have written "Submit" (capital S) ,where the name of your button is "submit" . so make it
if(isset($_POST['submit']))
I tried creating a simple PHP script to send an email to me when someone fills out a contact form on my website but I get nan error that says:
inspirehealth.today is currently unable to handle this request.
HTTP ERROR 500
<?php
$first_name = $_POST('first_name');
$last_name = $_POST('last_name');
$email = $_POST('email');
$message = $_POST('message');
$to = "lewkowicz613#gmail.com";
$subject = "Message from Inspire Health";
mail ($to, $subject, $message, "From: " . $first_name . $last_name);
echo "Your Message Has Been Sent";
?>
and here is my html file relevant to the form
<section class="section-form js--contact" id="contact">
<div class="row">
<h3>Please Subscribe to Our Email List!</h3>
</div>
<div class="row">
<form method="post" action="form_process.php" class="contact-form">
<div class="row">
<div class="col span-1-of-3">
<label for="first_name">First Name</label>
</div>
<div class="col span-2-of-3">
<input type="text" name="first_name" id="first_name" placeholder="First Name" required>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label for="last_name">Last Name</label>
</div>
<div class="col span-2-of-3">
<input type="text" name="last_name" id="last_name" placeholder="Last name" required>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label for="email">Email</label>
</div>
<div class="col span-2-of-3">
<input type="email" name="email" id="email" placeholder="Your email" required>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label for="message">Drop us a line</label>
</div>
<div class="col span-2-of-3">
<textarea name="message" id="message" placeholder="Your message" ></textarea>
</div>
</div>
<div class="row">
<div class="col span-1-of-3">
<label> </label>
</div>
<div class="col span-2-of-3">
<input type="submit" value="Send it!">
</div>
</div>
</form>
</div>
</section>
Im not sure why its not working properly. Is it a server thing because I uploaded all the files to my domain root directory.
Thanks a lot.
$_POST is a global array, so try:
<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = "lewkowicz613#gmail.com";
$subject = "Message from Inspire Health";
mail ($to, $subject, $message, "From: " . $first_name . $last_name);
echo "Your Message Has Been Sent";
?>
Hope this helps :)
I am very new to php and am trying to create a simple, secure and functioning contact form on a webpage. My form is as followed:
<form class="form-horizontal" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" >
<fieldset>
<div class="form-group">
<span class="col-md-1 text-center"><i class="fa fa-user bigicon"></i></span>
<div class="col-md-11">
<input id="fname" name="name" type="text" placeholder="Name" class="form-control">
</div>
</div>
<div class="form-group">
<span class="col-md-1 text-center"><i class="fa fa-envelope-o bigicon"></i></span>
<div class="col-md-11">
<input id="email" name="email" type="text" placeholder="Email Address" class="form-control">
</div>
</div>
<div class="form-group">
<span class="col-md-1 text-center"><i class="fa fa-pencil-square-o bigicon"></i></span>
<div class="col-md-11">
<textarea class="form-control" id="message" name="message" placeholder="Enter your massage for us here. We will get back to you within 2 business days." rows="7"></textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary btn-lg">Send</button>
</div>
</div>
</fieldset>
and I have the following php file (called mail.php) that I would like to execute when SEND button is pressed.
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent="From: $name \n Message: $message";
$recipient = "some.email#gmail.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");?>
Question is; if I have
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
how can I execute the php script in mail.php?