dqkf36241 2018-03-09 16:35
浏览 86

更改主机后Php电子邮件表单脚本无法正常工作

I'm just register for this problem I search for ten days and I don't find any solution.

I use for my sites php and simple HTML form. After I change the host provider the form stop working. After I complete the form and press submit it send you to the Error page and no email is sent to me.

I have the old host and I use the same files nothing change and it's working. I've tried to change the php version in cpanel not working same error. I've tried other simple scrips and it's working so I don't need smtp to send emails.

    <?
$numele=$_REQUEST['nume'];
$adresa=$_REQUEST['email'];
$telefon=$_REQUEST['tel'];
$comentariu=$_REQUEST['comentar'];
$catre="contact@mysite.ro";
$siteaddress ="http://www.mysite.ro";
$sitename = "Mysite.ro";

$mesaj="Un vizitator pe mysite.ro a lasat urmatorul mesaj:

Nume: $numele
Email: $adresa
Telefon: $telefon

Mesaj:
------------------------------
$comentariu";




if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.mysite.ro/index.html" );
  }
  elseif (empty($email) || empty($comentariu) || empty($numele) || empty($telefon)) {
    header( "Location: http://www.musite.ro/contact-eroare.html" );
  }
  else {
    mail($catre,"Contact Muri.ro",$mesaj,"From: $email" );
    header( "Location: http://www.mysite.ro/contact-mesaj-trimis.html" );
  }



//This sends a confirmation to your visitor
if (!isset($_REQUEST['email'])) {
    header( "Location: http://www.mysite.ro/index.html" );
  }
  elseif (empty($email) || empty($comentariu) || empty($numele) || empty($telefon)) {
    header( "Location: http://www.mysite.ro/contact-eroare.html" );
  }
  else {
    mail("$email","Multumim pentru interesul acordat produselor oferite de noi.",
    "Buna $numele,


Mesajul dvs. a fost inregistrat! Promitem sa raspundem in maxim 24 de ore. 


Cu respect,
$sitename
$siteaddress
$catre","FROM:$catre");
    header( "Location: http://www.mysite.ro/contact-mesaj-trimis.html" );
  }

?>

  • 写回答

1条回答 默认 最新

  • doucang5542 2018-03-10 05:04
    关注

    thanks for response! i tried the code still not working, same problem :( Look I use the code bellow and its working very well, but it s not so good like last one.

    `
    /*
    This first bit sets the email address that you want the form to be submitted to.
    You will need to change this value to a valid email address that you can access.
    */
    $webmaster_email = "contact@mysite.ro";
    
    /*
    This bit sets the URLs of the supporting pages.
    If you change the names of any of the pages, you will need to change the values here.
    */
    $feedback_page = "produse.html";
    $error_page = "contact-eroare.html";
    $thankyou_page = "contact-mesaj-trimis.html";
    
    /*
    This next bit loads the form field data into variables.
    If you add a form field, you will need to add it here.
    */
    $email_address = $_REQUEST['email'] ;
    $comments = $_REQUEST['comentar'] ;
    $first_name = $_REQUEST['nume'] ;
    $telef = $_REQUEST['tel'] ;
    $msg =
    "Nume: " . $first_name . "
    " . 
    "Telefon: " . $telef . "
    " . 
    "Email: " . $email_address . "
    " . 
    "Mesaj:
    " . 
    $comments ;
    
    /*
    The following function checks for email injection.
    Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
    */
    function isInjected($str) {
        $injections = array('(
    +)',
        '(+)',
        '(\t+)',
        '(%0A+)',
        '(%0D+)',
        '(%08+)',
        '(%09+)'
        );
        $inject = join('|', $injections);
        $inject = "/$inject/i";
        if(preg_match($inject,$str)) {
            return true;
        }
        else {
            return false;
        }
    }
    
    // If the user tries to access this script directly, redirect them to the feedback form,
    if (!isset($_REQUEST['email'])) {
    header( "Location: $feedback_page" );
    }
    
    // If the form fields are empty, redirect to the error page.
    elseif (empty($first_name) || empty($email_address) || empty($telef)) {
    header( "Location: $error_page" );
    }
    
    /* 
    If email injection is detected, redirect to the error page.
    If you add a form field, you should add it here.
    */
    elseif ( isInjected($email_address) || isInjected($first_name) || isInjected($telef)  || isInjected($comments) ) {
    header( "Location: $error_page" );
    }
    
    // If we passed all previous tests, send the email then redirect to the thank you page.
    else {
    
        mail( "$webmaster_email", "Contact mysite.ro", $msg );
    
        header( "Location: $thankyou_page" );
    }
    
    `
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?