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条回答 默认 最新

  • dpbvpgvrhwxen3222 2019-03-22 03:59
    关注

    The answer came to me after aaaaaa123456789 commented. I checked the error_log where it was returning:

    PHP Parse error: syntax error, unexpected '"Location: "' (T_CONSTANT_ENCAPSED_STRING)

    Fix: " ""Location: "

    To: " Location: "

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?