How to make functional my contact form

Hello,

I made my own contact form, but id doesn't work. I know I have to do something with .php file, some connection, but it still does'n work. I did everything I could. Could u help me pls? :(

Here is my html code:

<form class="cf" role="form" method="post" action="contact.php"> <div class="half left cf"> <input type="text" id="form" placeholder="Jméno"> <input type="email" id="form" placeholder="Email"> <input type="text" id="form" placeholder="Předmět"> </div> <div class="half right cf"> <textarea name="message" type="text" id="form" placeholder="Text"></textarea> </div>
<input type="submit" value="Poslat →" id="poslat"> </form>

Thank you very much for your help!

The forms won't function within the app or through preview.

You need to export your design and upload to your web server to get it to work.

Hello,

thank you for your answet, but it still does not work.

Here is my website: [http://stpn.mablog.eu/][1]

Here is code from contact.php

``` > > > > > > VV > > > > <?php if (isset($_POST["submit"])) { $name = $_POST['name']; > > $email = $_POST['email']; $subject = $_POST['subject']; $message > > = $_POST['message']; $from = 'Demo Contact Form'; $to = 'e-test8@seznam.cz'; $subject = 'Message from Contact Demo '; > > $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'; } > > //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 && !$errMessage && !$errHuman) { if > > (mail ($to, $subject, $body, $from)) { $result='
Thank You! I will be in touch
'; } else { > > $result='
Sorry there was an error > > sending your message. Please try again later
'; } } } ?> >
</blockquote>

Hi!

First you need to add the name="" attribute to the inputs on the html and remove the id=""

<form class="cf" action="contact.php" id="form">
<div class="half left cf”>
<input type="text" name="name" placeholder="Jméno">
<input type="email" name="email" placeholder="Email">
<input type="text" name="subject" placeholder="Předmět">
</div>
<div class=”half right cf”>
<textarea name="message" placeholder="Message"></textarea>
</div>
<input type="submit" value="Poslat →" name="send">
</form>

And the PHP file should be just this:

<?php
   if (isset($_POST["send"])) { 
 $name = $_POST['name'];
$email = $_POST['email'];  
$subject = $_POST['subject'];   
 $message = $_POST['message'];
$from = 'Demo Contact Form'; 
$to = 'e-test8@seznam.cz'; 
$subject = 'Message from Contact Demo ';
 $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';       }
 //Check if message has been entered    
     if (!$_POST['message']) {           $errMessage = 'Please enter your message';  }      
 // 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>';   
}
 }     
} ?>

Google is your friend. PHP is easy to learn. Spend some time

F

Your form will still only work once you have upload all your files to a server - it WILL NOT work in preview within the app.