Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.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联系人表单不工作_Php_Forms_Contact - Fatal编程技术网

PHP联系人表单不工作

PHP联系人表单不工作,php,forms,contact,Php,Forms,Contact,我正在为我正在做的一个辅助项目开发一种简单的表单 它基于一个非常简单的联系方式 我有一个非常相似的人在这里工作 但这里的那个似乎不起作用 下面的代码(非常新的网站,所以可能做了一些错误的事情) 感谢您提交新的入门表格。关于任何更新,我们将与您联系。 返回到品牌添加/a> 身体{ 字体大小:较大; 文本对齐:居中; } 新起动形式 开始日期: 地点: 曼彻斯特 伦敦 爱尔兰 列出所需的访问要求,其中应包括 •oasis访问级别或我们应该复制哪个用户来设置oasis访问级别 •用户应有

我正在为我正在做的一个辅助项目开发一种简单的表单

它基于一个非常简单的联系方式

我有一个非常相似的人在这里工作

但这里的那个似乎不起作用

下面的代码(非常新的网站,所以可能做了一些错误的事情)



感谢您提交新的入门表格。关于任何更新,我们将与您联系。
返回到品牌添加/a>

身体{ 字体大小:较大; 文本对齐:居中; }


新起动形式
开始日期:
地点:
曼彻斯特
伦敦
爱尔兰
列出所需的访问要求,其中应包括

•oasis访问级别或我们应该复制哪个用户来设置oasis访问级别
•用户应有权访问的公司程序
•员工需要访问的任何特定应用程序
•员工应该访问哪些共享驱动器文件夹

列出用户应该从

接收通信的电子邮件和电话组

台式计算机 笔记本电脑
手机 远程访问

在下面输入您的电子邮件进行通信


我不能保证这是您网站的唯一问题。但是,我可以保证这可以解决一两个问题。

在PHP代码中,您有一个
if
语句,用于确定
$\u POST[“email”]存在,对吗
我查看了您的HTML文档,在
中没有发现任何属性为
name=“email”
的内容。这将如何转移到您的PHP文档中?它不返回任何内容,因为页面基本上已死亡。我不确定“成功HTML”是否正确,但它可能与我要求您更改的
if
语句的右括号不合适有关。

如果您在
if
语句后添加
else
语句,我们可以测试这一理论,还要确保您正在提交输入或名称属性设置为“email”的内容。


**编辑:*在您的电子邮件文本框中,您的
名称属性设置为“submitter”。将其更改为“email”,然后修复代码,使其实际工作。这至少会给您一些反馈。

在您的代码中,您在哪里发送PHP文件中设置的POST requst“电子邮件”?我从未发现名称与“email”相等的发送请求。
isset
可能是您的问题,如果“email”没有发送到PHP文件。died()?我想你的意思是die(),在编写新脚本时总是启用错误显示,
error\u reporting(E\u ALL);ini设置(“显示错误”,1)
<?php

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

    // EDIT THE 2 LINES BELOW AS REQUIRED

    $email_to = "chris@crgdev.com";
    $email_subject = "New Starter - ";


    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['first_name']) ||
       !isset($_POST['last_name']) ||
       !isset($_POST['email']) ||
       !isset($_POST['accessrequirements'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $first_name = $_POST['first_name']; // required
    $last_name = $_POST['last_name']; // required
    $email_from = $_POST['email']; // required
    $accessrequirements = $_POST['accessrequirements']; // required

    $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,$first_name)) {
        $error_message .= 'The First Name you entered does not appear to be valid.<br />';
    }

    if(!preg_match($string_exp,$last_name)) {
        $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
    }

    if(strlen($accessrequirements) < 2) {
        $error_message .= 'The Comments you entered do not appear to be valid.<br      />';
    }

    if(strlen($error_message) > 0) {
        died($error_message);
    }

    $email_message = "Form details below.\n\n";


    function clean_string($string) {
        $bad = array("content-type","bcc:","to:","cc:","href");
        return str_replace($bad,"",$string);
    }


    $email_message .= "First Name: ".clean_string($first_name)."\n";
    $email_message .= "Last Name: ".clean_string($last_name)."\n";
    $email_message .= "Start Date: ".clean_string($start_date)."\n";
    $email_message .= "Job Title: ".clean_string($job_title)."\n";
    $email_message .= "Team Leader: ".clean_string($team_leader)."\n";
    $email_message .= "Location: ".clean_string($location)."\n";
    $email_message .= "Access Requirements: ".clean_string($accessrequirements)."\n";
    $email_message .= "Email/Phone Access: ".clean_string($emailaccess)."\n";
    $email_message .= "Other Requirements: ".clean_string($otherrequirements)."\n";
    $email_message .= "Subitted by: ".clean_string($email_from)."\n";


    // create email headers

    $headers = 'From: '.$email_from."\r\n".
               'Reply-To: '.$email_from."\r\n" .
               'X-Mailer: PHP/' . phpversion();

     @mail($email_to, $email_subject, $email_message, $headers);

?>



 <!-- include your own success html here -->



Thank you for submitting your New STarter Form. We will be in touch with you    regarding any updates.

<html>
<p>Go back to <a href="https://brandaddition.com">Brand Addition/a></p>
</html>

<style>
body {
    font-size: larger;
    text-align: center;
 }
</style>


<?php

}

?>
<body>
<div class="fixedwidth">

<div id="brandlogo"><img src="brandadditionlogo.png"</div>

<h1>New Starter Form</h1>
<div id="formdiv">
<form name="newstarterform" method="post" action="send_form_email.php">
<table id="formtable">
 <tr>
   <td><input  type="text" name="first_name" placeholder="First Name" maxlength="50"></td>
 </tr>
 <tr>
   <td><input  type="text" name="last_name" placeholder="Last Name" maxlength="50"></td>
 </tr>
 <tr>
    <td>Start Date: <input type="date" name="start_date" placeholder="Start Date" maxlength="50"></td>
 </tr>
 <tr>
    <td><input type="text" name="job_title" placeholder="Job Title" maxlength="50"></td>
 </tr>
 <tr>
    <td><input type="text" name="team_leader" placeholder="Team Leader" maxlength="50"></td>
 </tr>
 <tr>
    <td> Location:
        <select name="location">
        <option value="Manchester">Manchester</option>
        <option value="London">London</option>
        <option value="Ireland">Ireland</option>
        </select>
    </td>
 </tr>
 <tr>
   <td>
    <p class="pagepara"><span class="bold">List the access requirements needed, this should include</span><br><br>
      • Level of oasis access or which user we should copy to set the oasis access level<br>
      • Corporate programs that the user should have access to<br>
      • Any specific applications that the employee would need access to<br>
      • Which share drive folders should the employee have access to<br>
    </p>
    <textarea name="accessrequirements" placeholder="Access Requirements" maxlength="1000" cols="50" rows="10"></textarea>
   </td>
 </tr>
 <tr>
   <td>
    <p class="pagepara"><span class="bold">List the email and telephone groups that the user should receive<br> communications from</span><br><br>
    </p>
    <textarea name="emailaccess" placeholder="Email/Phone Access" maxlength="1000" cols="50" rows="10"></textarea>
   </td>
 </tr>
 <tr>
   <td>
     <input type="checkbox" name="desktop computer">Desktop Computer
     <input type="checkbox" name="laptop">Laptop <br>
     <input type="checkbox" name="mobile phone">Mobile phone
     <input type="checkbox" name="remote access">Remote Access<br><br>
     <textarea name="otherrequirements" placeholder="Other requirements not mentioned above?" maxlength="1000" cols="50" rows="10"></textarea>
   </td>
 </tr>
 <tr>
   <td>
     <p class="bold">Enter your email below for communications</p>
     <input type="email" name="submitter">
   </td>
 </tr>
 <tr>
   <td style="padding: 40px 0px 80px 0px">
     <input type="submit" value="Submit">
   </td>
  </tr>
  </table>
  </form>
</div>
 <div id="blueline"></div>
</div>
</body>