-2

I have coded a contact form in PHP and have an error please can you help me?

php Form code:

<form class="contact-form" action="submit.php" method="post"> 
              <div class="row">
                  <!--Name-->
                  <div class="col-md-6">
                      <input name="name" class="form-inp" type="text" placeholder="Name">
                  </div>
                  <!--Email-->
                  <div class="col-md-6">
                      <input name="email" class="form-inp" type="text" placeholder="Email">
                  </div>

                  <div class="col-md-12">
                      <!--Message-->
                      <textarea name="message" placeholder="How can I help you?" rows="7"></textarea>
                      <button name="submit" class="site-btn top_45 pull-right" type="submit">SUBMIT</button>
                  </div>
              </div>
          </form>

submit.php code

<?php
if (isset($_POST['submit']){
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$mailTo = "info@xxxx.com";
$headers = "From: ".$email;
$txt = "You have received an email from ".$name.".\n\n".$message;

mail($mailTo, $email, $message);
header("Location: index.php?mailsend");
}

Warning: Unknown: It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/brukitup/public_html/submit.php on line 2

Parse error: syntax error, unexpected '{' in /home/brukitup/public_html/submit.php on line 2

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
Ben Gali
  • 11
  • 3

1 Answers1

-2

Parse error: syntax error, unexpected '{' in /home/brukitup/public_html/submit.php on line 2

This error is because you're missing a ) in

if (isset($_POST['submit']){
                          ^^

As for your other warning, it's likely due to php settings. In your php.ini, set this

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = <whatever timezone you want to use>

(Source)

Arun A S
  • 6,421
  • 4
  • 29
  • 43