Vraag & Antwoord

Webprogrammeren & scripting

plaatsing stukje code in mailscript, maar waar?

Anoniem
WMP
1 antwoord
  • Heb een mailform gedownload met het volgende script

    ………………………………………………………………………………..
    [code:1:90a906cc92]
    <link href="css/style.css" rel="stylesheet" type="text/css" />

    <?php

    $status = $_GET['status'];

    if($status=="1") {

    echo '<div class="successAlert" style="width:560px; margin:auto">Message successfully sent!</div>';

    } elseif ($status=="0") {

    echo '<div class="warningAlert" style="width:560px; margin:auto">Your message was not sent. Please check your input!</div>';

    } else {

    echo"";

    }

    ?>
    <div class="container">
    <div class="content">
    <div class="shape">
    <div class="header">Contact us</div>
    <form method="post" id="form1" class="form" action="send_email.php">
    <table align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td><label for="name"><span class="pintext">Your name</span></label></td>
    <td><div align="left" class="string"><input class="name" type="text" name="name" id="name" size="32" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="email"><span class="pintext">Your email</span></label></td>
    <td><div align="left" class="string"><input class="email" type="text" name="email" id="email" size="32" /></div>
    </td>
    </tr>
    <tr>
    <td><label for="message"><span class="pintext">Your message</span></label></td>
    <td><div align="left" class="string_textarea">
    <textarea name="message" cols="24" rows="5" class="textarea" id="message"></textarea></div>
    <div align="right" class="footer_textarea"></div>
    </td>
    </tr>
    <tr>
    <td colspan="2"><div align="right"><input class="buttons" type="submit" name="Send message" id="Send message" value="Send message &rarr;" /></div>
    </td>
    </tr>
    </table>
    </form>
    </div>
    </div>

    en vervolgens:
    ………………………………………………………………………..
    <?php

    $site_name = "your site name here";
    $admin_email = "manilodisan@gmail.com";



    function check_email_address($email) {
    // First, we check that there's one @ symbol, and that the lengths are right
    if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
    header("Location: index.php?status=0");
    }
    // Split it into sections to make life easier
    $email_array = explode("@", $email);
    $local_array = explode(".", $email_array[0]);
    for ($i = 0; $i < sizeof($local_array); $i++) {
    if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
    header("Location: index.php?status=0");
    }
    }
    if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
    die ("Invalid email address");// Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
    if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
    header("Location: index.php?status=0");
    }
    }
    }
    return $email;
    }

    function escape_val($string) {
    $string = str_replace(array('"',"<",">"), array("&quot;","&lt;","&gt;"), $string);
    return $string;
    }


    $check_email = check_email_address($_REQUEST['email']);
    $name = escape_val($_REQUEST['name']);
    $message = escape_val($_REQUEST['message']);
    $time = date('l dS \of F Y h:i:s A');
    $email_subject = "New contact message from ".$site_name."";




    if(mail($admin_email,$email_subject,$message,"From:$check_email,Reply-to:$check_email")) {
    header("Location: index.php?status=1");
    exit;
    } else {
    header("Location: index.php?status=0");
    }
    ?>
    [/code:1:90a906cc92]
    en nu weet ik niet waar ik het volgende stukje code moet plaatsen

    Just edit "$site_name" and "$admin_email" from "send_email.php" and you're up and running!

    You can upload the whole "email" directory to your ftp and call the page in php like this:

    <?php
    include("email/index.php";);
    ?>

    Waar moet ik deze laatste regels precies plaatsen? Op elke webpagina van mijn website? .
    Jan

Beantwoord deze vraag

Dit is een gearchiveerde pagina. Antwoorden is niet meer mogelijk.