Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP Form Script for mail

    Hi!

    Please help, I downloaded the form mail script below and got stuck. Firstly do I separate the script so that everything before the <html> gets pasted on a blank text document and saved as fm.php which then gets uploaded to cgi-bin. Secondly do I paste all of the stuff in between the <html> tags and save it as an html page and upload?

    I guess I am sounding rather daft but I donít know the first thing so any help on how I can take what is claimed to be a working script, but does not come with a manual and configure it so that the website has a simple form mail.

    Thanks,
    Ishvir

    <?php
    // modify the three lines below
    $htmlMail = "no"; // "yes" to send html mail - otherwise sends text mail
    $emailAddress = "mail@domain.com"; // your email address
    $thankyouPage = ""; // leave empty to return to the form after a message has been sent - put in a url (or relative page) to go to a Thank You page
    // modify the three lines above
    session_start();
    if (isset($_POST['send']) AND isset($_SESSION['mail_count'])) {
    if (!preg_match("(^[-\w\.]+@([-a-z0-9]+\.)+[a-z]{2,4}$)i", $_POST['email'])) $alert = "You have entered an invalid email address.";
    if ($_SESSION['mail_count'] >= "3") $alert = "Only 3 messages can be sent per session.";
    if (empty($alert)) {
    $_SESSION['mail_count']++;
    if (!get_magic_quotes_gpc()) foreach ($_POST as $key=>$value) $_POST[$key] = addslashes($_POST[$key]);
    foreach ($_POST as $key=>$value) $_POST[$key] = wordwrap($_POST[$key],65);
    if ($htmlMail == "yes") {
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $message = "<table border='1'>";
    foreach ($_POST as $key => $value) if (!preg_match("(^send)", $key)) $message .="<tr><td><b>$key</b></td><td>$value</td></tr>";
    $message .= "</table>";
    } else {
    foreach ($_POST as $key => $value) if (!preg_match("(^send)", $key)) $message .= $key . "->\n " . $value . "\n\n";
    }
    $subject = $_SERVER['HTTP_HOST'] . " Message";
    $headers .= "From: <" . $_POST['email'] . ">\r\n";
    mail($emailAddress,$subject,$message,$headers);
    if (!empty($thankyouPage)) {
    header('location: ' . $thankyouPage);
    die();
    }
    unset($_POST);
    $alert = "Your message has been sent.";
    }
    }
    if (!isset($_SESSION['mail_count'])) $_SESSION['mail_count'] = 0;
    ?>
    <html>
    <head>
    </head>
    <body>
    <form method="post" action="<?php echo $_SERVER["SCRIPT_NAME"]; ?>">
    <div style="text-align: center; height: 450px; width: 500px; margin-top: 50; border: solid 1px black;">
    <br>
    Send me a message<br><br>
    your name<br><input type="text" style="width: 330px;" name="name" value="<?php echo $_POST['name']; ?>" maxlength="50"><br><br>
    your email address<br><input type="text" style="width: 330px;" name="email" value="<?php echo $_POST['email']; ?>" maxlength="50"><br><br>
    your message<br><textarea name="content" style="width: 330px; height: 100px;" rows="6" cols="80"><?php echo $_POST['content']; ?></textarea>
    <br><br>
    <input type="submit" name="send" value="submit">
    </div>
    </form>
    <?php if (isset($alert)) echo "<script type='text/javascript'>alert('$alert');</script>"; ?>
    </body></html>

  • #2
    Regular Coder
    Join Date
    May 2006
    Location
    Wales
    Posts
    820
    Thanks
    1
    Thanked 82 Times in 79 Posts
    You just put it all together in one php file and upload it just as you would upload a html file

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    Los Angeles
    Posts
    545
    Thanks
    81
    Thanked 5 Times in 5 Posts
    Is your mail form not working?
    RalphF
    Business Text Messaging Services
    https://www.MobileTextingService.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •