Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
您可以在引导页面上创建一个PHP联系人表单而不使用div和form类吗?_Php_Html_Twitter Bootstrap_Forms - Fatal编程技术网

您可以在引导页面上创建一个PHP联系人表单而不使用div和form类吗?

您可以在引导页面上创建一个PHP联系人表单而不使用div和form类吗?,php,html,twitter-bootstrap,forms,Php,Html,Twitter Bootstrap,Forms,我不是在本地运行此程序,而是在现场运行/调试此问题 我的意思是,我看到的很多例子中似乎有太多的标记。我正在尝试实现一个简单的联系人表单,我的PHP似乎运行得很好,它在提交时显示警报,但不发送电子邮件。我不确定这是否是由于我的PHP,但它似乎编译得很好 这两台机器的接线方式有问题吗 HTML剪报: <form id="contactForm" class="" role="form" method="post" action="contactHandler2.php">

我不是在本地运行此程序,而是在现场运行/调试此问题

我的意思是,我看到的很多例子中似乎有太多的标记。我正在尝试实现一个简单的联系人表单,我的PHP似乎运行得很好,它在提交时显示警报,但不发送电子邮件。我不确定这是否是由于我的PHP,但它似乎编译得很好

这两台机器的接线方式有问题吗

HTML剪报:

<form id="contactForm" class="" role="form" method="post"   action="contactHandler2.php">

     <input id="name" type="text" placeholder="NAME" name="name">

     <input class="input-twin" id="email" name="email" type="text" placeholder="E-MAIL">

     <input type="tel" class="input-twin" name="phone" placeholder="PHONE">

     <select name="focus" id="contact-focus">
        <option value="" disabled selected>Interested In...</option>
        <option value="v0">Opt1 Inquiry</option>
        <option value="v1">Opt2</option>
        <option value="v2">Opt3</option>
     </select>

     <textarea id="message" name="message" type="text" placeholder="Details, Availability, Questions, etc"></textarea>

     <input id="submit" type="submit" value="GO!">

</form>

对……感兴趣。。。
Opt1查询
Opt2
Opt3
PHP:


检查您的托管邮件服务。您可以尝试使用此库轻松配置使用SMTP发送电子邮件发现问题。首先,它是一个共享服务器,所以一些邮件设置在默认情况下是关闭的,不确定我是否可以访问它们。聊天支持对此有所帮助。这是他们所能做的

首先我在服务器上创建了一封用户电子邮件,我想他们给我的登录名没有默认的


我还看到,我不小心设置了来自用户表单的电子邮件的headers值,而不是来自服务器的邮件。所以我将它硬编码到我在管理控制台中创建的名称,然后它开始工作

如果您在localhost上运行它,那么您需要做更多的设置(检查如何在php中通过localhost发送邮件)。如果您要将其运行到某个服务器,则需要在该服务器上进行邮件配置。同时也应用一些错误报告来检查是否发生错误?(可能是因为该错误导致您的php死机了)@Anant它运行在一个名便宜的服务器上,我已经检查了,并且服务器配置了PHP5.3…我认为这足以让mail()在本地执行可能的重复操作。服务器位于namescape上,并使用PHP5.3进行配置
<?php

if(isset($_POST['email'])) {



// EDIT THE 2 LINES BELOW AS REQUIRED

$email1 = "myemail@gmail.com";
$email2 = "myotheremail@gmail.com";

$email_subject = "PT Website Inquiry";





function died($error) {

    // your error code can go here

    echo "We are very sorry, but there were error(s) found with the form you submitted. ";

    echo "These errors appear below.<br /><br />";

    echo $error."<br /><br />";

    echo "Please go back and fix these errors.<br /><br />";

    die();

}



// validation expected data exists

    if(!isset($_POST['name']) || !isset($_POST['email']) ||     !isset($_POST['message'])) {

    died('We apologize, but something weird happened. Please try again.');

}

$name = $_POST['name']; //

$email_from = $_POST['email']; //

$phone = $_POST['phone']; //

$focus = $_POST['focus'];

$message = $_POST['message']; //


$error_message = "";

$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

 if(!preg_match($email_exp,$email_from)) {

 $error_message .= 'The Email Address you entered does not appear to be valid.<br />';

}

$string_exp = "/^[A-Za-z .'-]+$/";

if(!preg_match($string_exp,$name)) {

$error_message .= 'The First Name you entered does not appear to be valid.<br />';

}

if(strlen($message) < 2) {

 $error_message .= 'The message you entered do not appear to be valid.  <br />';

 }

if(strlen($error_message) > 0) {

  died($error_message);

 }

$email_message = "Someone submitted our website's contact form, here are the details:\n\n";



function clean_string($string) {

  $bad = array("content-type","bcc:","to:","cc:","href");

  return str_replace($bad,"",$string);

 }



$email_message .= "Name: ".clean_string($name)."\n";

$email_message .= "Email: ".clean_string($email_from)."\n";

$email_message .= "Phone: ".clean_string($phone)."\n\n";

$email_message .= "They expressed interest in: ".clean_string($focus)."\n\n";

$email_message .= "Message: \n\n".clean_string($message)."\n\n";


$email_message .= "****************\n
                   DO NOT REPLY\n
                   ****************";


// create email headers

$headers = 'From: '.$email_from."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();

mail($email1, $email_subject, $email_message, $headers);
mail($email2, $email_subject, $email_message, $headers);


// header('Location: http://allcalrecycling.com');

echo "<script>
alert('Thank you! We will reach out shortly.');
window.location.href='index.html';
</script>";


?>


<?php

 }

?>