40 users online (0 members and 40 guests)  


  Results 1 to 1 of 1

Related

  1. Php Mail script being Spammed    Forum: PHP Forum
    Replies: 7
  2. PHP Form Mail Problem    Forum: PHP Forum
    Replies: 30
  3. problem with function mail()    Forum: PHP Forum
    Replies: 6
  4. Send Mail Problem    Forum: CGI Perl Forum
    Replies: 11
  5. php mail script help    Forum: PHP Forum
    Replies: 14
  1. #1
    adamsen's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Jan 2009
    Location
    Denmark
    Posts
    128

    Problem with mail-script

    I´ve made a form which should be able to send me some informations.
    On the internet I found a PHP-script that could help me with
    that, but it doesn´t work. When you press the Send-button, I recive an email, but it doesn´t have any content. I hope someone can see what is wrong:

    Html:
    HTML Code:
    <form method="post" action="../../php/mail_phpscript.php" enctype="text/plain" name="bestilling">
    Hus/værelse:<br>
    <input type="text" name="Hus"
    value="Det store hus, soveværelset" size="25" readonly="readonly">
    <br><br>
    Reserverede datoer:<br>
    <input type="text" name="datoer" size="25" id="datoer">
    <br><br>
    Navn/familie:<br>
    <input type="text" name="navn" size="20">
    <br><br>
    Email:<br>
    <input type="text" name="email" size="20">
    <br><br>
    Telefonnummer:<br>
    <input type="text" name="fasttlf" size="20">
    <br><br>
    <input type="submit" value="Send"></form>
    PHP:
    PHP Code:
    <?php
    /* All form fields are automatically passed to the PHP script through the array $HTTP_POST_VARS. */
    $email 'michaelhoffadamsen@gmail.com';
    $subject 'Email-tilmelding';
    $message $HTTP_POST_VARS['datoer'];

    /* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
    if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/"$email)) {
      echo 
    "<h4>Invalid email address</h4>";
      echo 
    "<a href='javascript:history.back(1);'>Back</a>";
    } elseif (
    $subject == "") {
      echo 
    "<h4>No subject</h4>";
      echo 
    "<a href='javascript:history.back(1);'>Back</a>";
    }

    /* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */
    elseif (mail($email,$subject,$message)) {
      echo 
    "<center><h1>Informationerne er sendt</h1></center>";
    } else {
      echo 
    "<h4>Fejl</h4>";
    }
    ?>
    All this is uploaded on:

    http://www.ullilo.dk/reservering/storehus_sovevaerelse/recieve.htm
    Last edited by HTML; 03-08-2012 at 04:19 PM.



Tags for this Thread