Very simple feedback form, please help for the noob!

Discussion in 'PHP' started by karya_xx, Nov 28, 2007.

  1. #1
    Hi all,

    here my simple code:

    
    <?php
      
    $name = $_REQUEST['name']; 
    $email = $_REQUEST['text']; 
    $comment = $_REQUEST['comment']; 
    
    mail( "mymail@xyz.xz", "Feedback Form",
    $name, $comment, "From: $email" );
    header( "Location: http://www.megawhite.au" );
    
    ?>
    
    Code (markup):
    I need to check, if ALL of the fields are filled. If yes - then go to www.megawhite.. if NOT - to some other www.

    I know, that it is somehow possible with "empty" command.. :rolleyes:

    Can You put me on the right way, please?

    Thanx.
     
    karya_xx, Nov 28, 2007 IP
  2. drunnells

    drunnells Peon

    Messages:
    79
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    how about:

    if ($name && $email && $comment) {
         header( "Location: http://www.megawhite.au" );
    } else {
         header( "Location: http://www.someothersite.com" );
    }
    PHP:
    ?
     
    drunnells, Nov 28, 2007 IP
  3. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #3
    name: 1, email: 1, comment: 1
    form filled!

    How about:

    Turn register_globals off first.

    
    <?PHP
    if (!empty($_POST['email'])) && preg_match("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])", $_POST['email'])) {
      $email = $_POST['email'];
    }
    if (!empty($_POST['name'])) && preg_match("/^[A-Za-z]{1,}\s[A-Za-z\']{2,}$/", $_POST['name'])) {
      $name = $_POST['name'];
    }
    if (!empty($_POST['comment']) && preg_match("/^[A-Za-z0-9\s.-\#\@\x10\x13]{10,}$/")) {
      $comment = $_POST['comment'];
    }
    
    if (isset($name) && isset($email) && isset($comment)) {
      header("Location: http://www.megawhite.au/", 200);
    } else {
      header("Location: http://www.google.com.au/", 403);
    }
    
    ?>
    
    PHP:
     
    zacharooni, Nov 28, 2007 IP
  4. karya_xx

    karya_xx Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    the globals are turning off on my host? i have done it in the begining, if i understood correctly
     
    karya_xx, Nov 29, 2007 IP