0

I have tried to create a simple form with the html and php code shown below. HTTP ERROR 500 keeps occurring when I try run the page. Please advise how I am able to receive an email when a form is submitted.Thank you in advance.

         <form action="action_page.php" method="post" target="_blank">

            <div class="info">
             <input class="name" type="text" name="name" placeholder="Full name">
             <input type="text" name="email" placeholder="Email">
             <input type="text" name="number" placeholder="Phone number">
             <input type="text" name="date" placeholder="Today's date"><br>

             <select id="product" name="product">
              <option value="LENOVO THINKPAD T460 LAPTOP">LENOVO THINKPAD T460 LAPTOP- 
               R4500</option>
              <option value="LENOVO THINKPAD T450 LAPTOP">LENOVO THINKPAD T450 LAPTOP- 
               R4000</option>
              <option value="LENOVO THINKCENTRE M93 DESKTOP">LENOVO THINKCENTRE M93 DESKTOP- 
               R3250</option>
              </select>

              <input type="number" name="amount" placeholder="Quantity" min="0"><br>

              <button><input type="submit" value="Submit" ></button>
  </div>
 </form>


<?php 
 if (isset(S_POST{'submit'})){

  $name = $_POST['name'];
  $email = $_POST['email'];
  $number = $_POST['number'];
  $product = $_POST['product'];
  $amount = $_POST['amount'];



     $to='amy@ethers.co.za';
      $subject='Form Submission';
      $message="Name: ".$name."\n"."Email: ".$email."\n"."Product: ".$product."\n"."Amount: 
      ".$amount.
      $headers="From: ".$email;

     if(mail($to, $subject, $message,

 $headers)){
  echo "<h1>Sent Succesfully! Thank You!</h1>";
  }
   else{
    echo "Something went wrong";
  }
}
?>
Sarah
  • 1
  • Error 500 means somewhere in your Laravel and/or webserver logs lies a useful error message. Finding it will help you immensely. – ceejayoz Apr 30 '20 at 16:01
  • 1
    Probably a parse/syntax error with `S_POST{'submit'}` – aynber Apr 30 '20 at 16:03
  • Your code failed for a few reasons. 1) Unclosed statement in `$message....` (first parse error) 2) `if (isset(S_POST{'submit'})){...}` won't do anything for now because of the input name not being matched per what @aynber stated. The braces `{}` need to be brackets `[]`. – Funk Forty Niner Apr 30 '20 at 16:04

0 Answers0