开发者

Email form within website (not mailto link), which language? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to开发者_运维问答 be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I was wondering what language I need to use in order to create a simple form for emailing an email address on a website.

What language do I need to use in order to make this happen, and does it need to be server-side? I would imagine so.


Without using a "mailto:" link, this will need to be server side. The language you use may be restricted by the hosting platform, and what languages are supported, or for which support can be added.


Yup server side.. I use a combination of PHP and AJAX to achieve this, with a CAPTCHA system integrated in. $_SESSION variables pass through AJAX calls, hence the CAPTCHA works with AJAX.

Here's the most basic form of a PHP mailer...

$to = "info@sonikastudios.com";
    $subject = "Website inquiry from ".$_POST['name'];
    $content = "
    <html>
        <head>
            <title></title>
        </head>
    <body>
    <p>
    Name: ".$_POST['name']."<br />Phone: ".$_POST['phone'].'<br />Email: '.$_POST['email'].'<br />Referred By: '.$_POST['referred'].'<br /><br />'.nl2br($_POST['message']).
    '
    </body>
    </html>
    ';

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    $headers .= 'From: '.$_POST["email"];


    mail($to,$subject,$content,$headers);
    echo "<font color=\"#0c0\">Your message has been sent.</font>";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜