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: "

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题