Email Form PHP HELP~!

PichuSecretBase

Web Site Critique
  • 2,775
    Posts
    21
    Years
    PHP:
    <form name="form" method="post" action="mail.php">
    <p>Name: <input type="text" name="name"></p>
    <p>E-Mail: <input type="text" name="email"></p>
    <p>Site Name: <input type="text" name="site"></p>
    <p>Site URL: <input type="text" name="url"></p>
    <input type="submit" name="Submit" value="Submit">
    </form>

    PHP:
    <?php
    mail("[email protected]", "Exchange", $message) ;
    ?>
    <?php 
    $message = "$name, $email, $site, $url" ?>


    Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 3

    What's wrong >>
     
    You forgot to define your variables name, email, site, and url. You also needed to define the message variable before you do the mail function. Try this:
    PHP:
    <?php
    if ($HTTP_POST_VARS){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $site = $_POST['site'];
    $url = $_POST['url'];
    $message = 'echo "$name <br /> $email <br /> $site <br /> $url"';
    mail("[email protected]","Exchange",$message)
    }
    ?>
    <form name="form" method="post" action="mail.php">
    <p>Name: <input type="text" name="name"></p>
    <p>E-Mail: <input type="text" name="email"></p>
    <p>Site Name: <input type="text" name="site"></p>
    <p>Site URL: <input type="text" name="url"></p>
    <input type="submit" name="Submit" value="Submit">
    </form>
    Call the thing mail.php or you can take the PHP code out and put it in a file called mail.php. If you do that, then take out the "if ($HTTP_POST_VARS){" and the "}" at the end. If it stills gives you problems, I try to help you out.
     
    [disable]Parse error: syntax error, unexpected '}' in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 9

    I got that error[/disable]
     
    Oops. Take the "}" out. That shouldn't be there. Sorry, my mistake. :P
     
    [disable]
    Parse error: syntax error, unexpected $end in C:\apachefriends\xampp\htdocs\PSB\exchange\form\mail.php on line 10[/disable]

    Gahh XD
     
    PHP:
    <?php
    if ($HTTP_POST_VARS){
    $name = $_POST['name'];
    $email = $_POST['email'];
    $site = $_POST['site'];
    $url = $_POST['url'];
    mail("[email protected]","Exchange","$name  
    $email  
    $site 
    $url");
    }
    ?> 
    <form name="form" method="post" action="bob.php">
    <p>Name: <input type="text" name="name"></p>
    <p>E-Mail: <input type="text" name="email"></p>
    <p>Site Name: <input type="text" name="site"></p>
    <p>Site URL: <input type="text" name="url"></p>
    <input type="submit" name="Submit" value="Submit">
    </form>
    That's the correct code. It'll work. If you get a blank email about this, I acciently press submit while testing it. If you get your orignal error, it maybe because it'll try to send an email using your domain and it might not work depending on your host I guess from my testing it.
     
    Back
    Top