Advertisement
Ilai

Untitled

Jul 8th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. מעל תגית HTML
  2.  
  3. <?php
  4.     if (empty($_POST) == false){
  5.         $errors = array();
  6.        
  7.         $name        = $_POST['name'];
  8.         $email       = $_POST['email'];
  9.         $message     = $_POST['message'];
  10.        
  11.         if (empty($name) == true || empty($email) == true || empty($message) == true) {
  12.             $errors[] = '! נא למלא את כל השדות';
  13.         } else {
  14.             if (filter_var($email, FILTER_VALIDATE_EMAIL) == false) {
  15.                 $errors[] = '! האימייל אינו חוקי';
  16.             }
  17.             if (ctype_alpha($name) == false) {
  18.                 $errors[] = '! השם חייב להכיל רק אותיות';
  19.             }
  20.         }
  21.        
  22.         if (empty($errors) == true) {
  23.             mail('ilaibens14@gmail.com', 'contact form', $message, 'Form: ' . $email);
  24.             header('Location: index.php?sent');
  25.             exit();
  26.         }
  27.     }
  28. ?>
  29.  
  30. הטופס:
  31.                     <div class="col-md-6 col-sm-12">
  32.                         <?php
  33.                             if (isset($_GET['sent']) == true) {
  34.                                 echo '<p>! תודה לך על ההודעה, נשתדל לענות במהרה</p>';
  35.                             } else {
  36.                        
  37.                                 if (empty($errors) == false) {
  38.                                     echo '<ul>';
  39.                                     foreach($errors as $error) {
  40.                                         echo '<li>', $error, '</li>';
  41.                                     }
  42.                                     echo '</ul>';
  43.                                 }
  44.                             ?>
  45.                             <form method="post" action="" class="wow fadeInUp" data-wow-delay="0.6s">
  46.                                 <div class="col-md-6 col-sm-6">
  47.                                     <input type="text" class="form-control" placeholder="Name" name="name" <?php if (isset($_POST['name']) == true) { echo 'value="', strip_tags($_POST['name']), '"';  } ?> >
  48.                                 </div>
  49.                                 <div class="col-md-6 col-sm-6">
  50.                                     <input type="email" class="form-control" placeholder="Email" name="email" <?php if (isset($_POST['email']) == true) { echo 'value="', strip_tags($_POST['email']), '"';  } ?> >
  51.                                 </div>
  52.                                 <div class="col-md-12 col-sm-12">
  53.                                     <textarea class="form-control" placeholder="Message" rows="7" name="message"><?php if (isset($_POST['message']) == true) { echo strip_tags($_POST['message']);  } ?></textarea>
  54.                                 </div>
  55.                                 <div class="col-md-offset-4 col-md-8 col-sm-offset-4 col-sm-8">
  56.                                     <input type="submit" class="form-control" value="SEND MESSAGE">
  57.                                 </div>
  58.                             </form>
  59.                         <?php
  60.                         }
  61.                         ?>
  62.                     </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement