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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘