duanph1978 2019-03-22 03:12
浏览 71
已采纳

联系人提交按钮重定向到空白.PHP网址?

I have a contact form that I would like to send to my email address at my domain. However, upon hitting the "Submit" button, the website gets redirected to the .PHP url where it gives me:

HTTP ERROR 500: This page isn’t working "mywebsite.com" is currently unable to handle this request.

No email is received and the header("Location: ") doesn't redirect. I am currently using Bluehost. You can find the form I'm working on at acromojo.com/contact. I haven't added security yet, just trying to get the form to work first.

What am I doing wrong?

HTML:

<form method="post" action="contactform.php">

    <div><select name="projectType">
      <option value="0">Start A Project</option>
      <option value="1">General Inquiry</option>
      <option value="2">Collaborating</option>
    </select></div></br>
    <input name="name" type="text" placeholder="Full Name" required>
    <input name="company" type="text" placeholder="Company / Organization"></br>
    <input name="phone" type="phone" placeholder="Phone Number" required>
    <input name="email" type="email" placeholder="Email Address"></br>
    <input name="location" type="text" placeholder="Location">
    <select name="find">
      <option value="0">How did you hear about us?</option>
      <option value="1">Social Media</option>
      <option value="2">Search Engine</option>
      <option value="3">Referrals / Recommendations</option>
      <option value="4">Other</option>
    </select></br></br>
    <textarea name="message" placeholder="Please tell us a little about your project, timeline, and budget" row="4" required></textarea></br>
    <label>Sign me up for the latest news, events, and more
      <input name="newsletter" type="checkbox" checked="checked">
      <span class="checkmark"></span>
    </label>
        <input type="submit" name="submit" value="SUBMIT">

</form>

PHP:

<?php

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

    $name = $_POST['name'];
    $subject = $_POST['projectType'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $location = $_POST['location'];
    $find = $_POST['find'];
    $message = $_POST['message'];
    $newsletter = $_POST['newsletter'];

    $headers = "From: $email";
    $txt = "You have received an e-mail from ".$name."

"
      "Location: ".$location."
"
      "Contact: ".$phone.", ".$email."
"
      "Found from: ".$find."

"
      .$message;

    mail("hello@acromojo.com", $subject, $txt, $headers);
    header("Location: contact.html?mailsent");
  }
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥30 Abaqus做建模的时候网格没办法收敛是为什么?
      • ¥15 车牌识别摄像镜头,httppost,nodejs
      • ¥20 腾讯云托管与本地测试 GET请求获取返回值 完全不同
      • ¥15 C语言有关数组的问题
      • ¥15 edge跟谷歌浏览器的默认搜索引擎无法修改,如何解决?
      • ¥15 access数据库出错
      • ¥100 matlab数学建模习题,求解答
      • ¥15 blender python输出纹理坐标(像素级)与三维坐标的对应关系
      • ¥15 python文件分发
      • ¥15 关于#c语言#的问题:要求:输出格式要界面直观、清晰大方、格式规范