+ -
当前位置:首页 → 问答吧 → 整PHP contact form遇到问题

整PHP contact form遇到问题

时间:2012-06-08

来源:互联网

我在帮公司整一个网页, 用PHP contact form整一个inquiry page, 俾人填名、电话、email等, 想按”send”就会将d资料变成个email send 去我个mail box度,
而我其实唔算好识呢d, 个inquiry page都系用呢个网讲ge野改出泥ge: http://myphpform.com/php-form-tutorial.php

==============================================================

<?php
date_default_timezone_set('Asia/Hong_Kong');
ini_set("sendmail_from","*******@yahoo.com.hk";
ini_set("SMTP","smtp.wtt-mail.com";

/* Set e-mail recipient */
$myemail  = "****************@yahoo.com.hk";
/* Check all form inputs using check_input function */
$company = check_input($_POST['company'], "enter your company's name";
$person = check_input($_POST['person'], "enter your name");
$tel = check_input($_POST['tel'], "enter your contact number");
$email = check_input($_POST['email'], "Please enter your E-mail");
$subject  = "Online Enquiry";
/*$content = check_input($_POST['content'], "Write your content");*/

/* If e-mail is not valid show error message */
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
    show_error("E-mail address not valid");
}
/* If URL is not valid set $website to empty */
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
    $website = '';
}

/* Let's prepare the message for the e-mail */
$message = "Hello!
CTC-940 contact form has been submitted by:
Company Name: $company
Contact Person: $person
Tel: $tel
E-mail: $email
Content:
$content
End of message

";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
/* Redirect visitor to the thank you page */
/* Location: http://www.******.com/ */

header("ThankYou.html");

exit();
/* Functions we used */
function check_input($data, $problem='')
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0)
    {
        show_error($problem);
    }
    return $data;
}
function show_error($myError)
{
?>

   
        
        
        
        
   


    correct the following error:

   


               
               
                        
               


  
   
<?php
ob_end_flush();
exit();
}
?>
==============================================================
我send完想个网跳去thank you page度, 但会出现句 ”Cannot modify header information – header already sent by (output started at C:\inetpub\wwwroot\contant2.php:1) in C:\inetpub\wwwroot\contant2.php on line 45”

Line45姐系「header("ThankYou.html");」呢行

上网搵过解决方法, 试咗
1.        我个php.ini的output_buffering一直是on的
2.        在header后加exit();
3.        加上同ob_end_flush();

个email系send到, 填漏资料都识跳去error page, 但就系去唔到页thank you page…都系Cannot modify header information(略)

请问系唔系我改得唔啱?有咩解决方法呢?

作者: JK0213   发布时间: 1970-01-01

你应该漏左location
header("location: ThankYou.html");
http://php.net/manual/en/function.header.php

[ 本帖最后由 豪狗仔 於 2012-6-8 08:28 PM 编辑 ]

作者: 豪狗仔   发布时间: 1970-01-01

热门下载

更多