php form help!!

Discussion in 'PHP' started by muchochiz, Jun 10, 2011.

  1. #1
    hi guys please i need help with my php form . here is the html
    <html>
    <head><title>test1</title></head>
    <body>
    <form action="next2.php" method="post">
    Name:
    <input type="text" name="name">
    
    Email:
    <input type="text" name="email">
    Mail:
    <input type="textarea" row="7" cols="70"name="message">
    
    <input type="submit"value="send your message" >
    </form>
    </body>
    </html>
    HTML:
    here is the php

    <?php
    
    $name=$_POST['name'];
    $email=$_POST['email'];
    $mail=$_POST['message'];
    
    Name:$name\n
    Email:$email\n
    Message:$mail\n
    
    
    //to, message, header
    mail('me@myemail.com',"$mail",'From:'. $name.'<'.$email.'>');
    header('location: http://www.mywebsite')
    
    ?>
    
    PHP:
    please what am i doing wrong here .
     
    muchochiz, Jun 10, 2011 IP
  2. TheMarketeer

    TheMarketeer Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What error are you receiving? We should start by finding out what you are looking to resolve. Thanks!
     
    TheMarketeer, Jun 10, 2011 IP
  3. shofstetter

    shofstetter Well-Known Member

    Messages:
    178
    Likes Received:
    7
    Best Answers:
    1
    Trophy Points:
    120
    #3
    your code has a few errors:

    
    <?php
    
    $name=$_POST['name'];
    $email=$_POST['email'];
    $mail=$_POST['message'];
    
    /****     either needs to be commented out or echo'd   ****/
    echo "Name:$name\n";
    echo "Email:$email\n";
    echo "Message:$mail\n";
    
    
    //to, message, header
    mail('me@myemail.com',"$mail",'From:'. $name.'<'.$email.'>');
    header('location: http://www.mywebsite');// forgot the semi colon ;
    
    ?>
    
    
    PHP:

    That's all I see at the moment
     
    shofstetter, Jun 10, 2011 IP
  4. The Webby

    The Webby Peon

    Messages:
    1,852
    Likes Received:
    30
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Your code wont work either.. You can not modify header once the output started. So you can not echo anything (even a white space) if you want to modify your header somewhere later in the script.

    This should work:
    
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $mail = $_POST['message'];
    
    //to, message, header
    mail('me@myemail.com',"$mail",'From:'. $name.'<'.$email.'>');
    header('location: http://www.mywebsite');
    ?>
    
    PHP:
     
    The Webby, Jun 11, 2011 IP