3 Replies - 557 Views - Last Post: 14 October 2012 - 11:42 AM Rate Topic: -----

#1 emaricela87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-October 12

How can I send an automatic "thankyou.html" upon pressing "

Posted 13 October 2012 - 10:10 AM

I'm having trouble showing up the contact.php (shows a blank page) when I press submission on my form index.php.
Where am I going wrong and am I saving the files right?
Thank You.

//index.php 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- feedback2.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="css/default.css" />
    <title>Contact Us</title>
  </head>
  <body>
    <h4>Feedback Form ... Let Us Know What You Think</h4>
    <form action="contact.php" method ="post">
    <input type = "hidden" name = "redirect" value = "thankyou.htm"/>	
      <table summary="Feedback Form Version 2 with Submit, Reset Buttons">
       
	
        <tr valign="top">
          <td>First Name:</td>
          <td><input type="text" name="firstName" size="40" /></td>
        </tr>
        <tr valign="top">
          <td>Last Name:</td>
          <td><input type="text" name="lastName" size="40" /></td>
        </tr>
        <tr valign="top">
          <td>E-mail Address:</td>
          <td><input type="text" name="email" size="40" /></td>
        </tr>
        <tr valign="top">
          <td>Phone Number:</td>
          <td><input type="text" name="phone" size="40" /></td>
        </tr>
        <tr valign="top">
          <td>Subject:</td>
	  <td><select name="subject">
            <option> </option>
            <option>Feedback</option>
            <option>Suggestion</option>
            <option>Site error</option>
          </select></td>
        </tr>
        <tr valign="top">
          <td>Comments:</td>
          <td><textarea name="message" rows="6" cols="30">
          </textarea></td>
        </tr>
        <tr>
          <td colspan="2">Please check here if you wish to receive a reply:
          <input type="checkbox" name="reply" value="yes" /></td>
        </tr>
        <tr>
          <td><input type="submit" value="Send Feedback" /></td>
          <td align="right"><input type="reset" value="Reset Form" /></td>
        </tr>
      </table>
    </form>
  </body>
</html>




//contact.php
<?php



$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];

$to = "mesmeralda@uh.edu";
$subject = $_POST['subject'];
$msg = $message . $_POST['name'] .
$headers = "From: " .$_POST['email'] . "\r\nReply-To:" . $_POST['email'];


mail("$to", $subject", "$msg", "$headers");

header("Location: thankyou.html");
?>





//thankyou.html
<html>
<body>

<p><b>Your message was sent</b></p>

<p>Your message was successfully sent!
Thank you for contacting us, we will reply
to your inquiry as soon as possible!</p>

</body>
</html>

This post has been edited by Atli: 13 October 2012 - 10:20 AM
Reason for edit:: Please use [code] tags when posting code.


Is This A Good Question/Topic? 0
  • +

Replies To: How can I send an automatic "thankyou.html" upon pressing "

#2 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3712
  • View blog
  • Posts: 5,964
  • Joined: 08-June 10

Re: How can I send an automatic "thankyou.html" upon pressing "

Posted 13 October 2012 - 10:28 AM

Typically when you see a blank page where there should be something, there is an error preventing the page from being displayed, but your PHP installation is not configured to show you the error. - You should always enable error reporting on development machines. You do that by editing the "php.ini" file so that display_errors is set to "On", and error_reporting is set to "E_ALL".

The problems in that script, however, are two:

  • You end line #14 with a dot, where you should be using a semi-colon.

  • In the "mail()" call, you are unnecessarily quoting your variables. (You don't have to do "$var". Just do $var.) - By itself, that is not a fatal error though. But you left out the opening-quote (or rather, appended an unnecessary quote behind the variable), which is a syntax error, which leads to your blank page.

Was This Post Helpful? 2
  • +
  • -

#3 NathanMullenax  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 83
  • View blog
  • Posts: 176
  • Joined: 23-September 12

Re: How can I send an automatic "thankyou.html" upon pressing "

Posted 13 October 2012 - 10:45 AM

Looks like there's a missing double-quote mark before subject in the 'mail(...)' line.
Was This Post Helpful? 1
  • +
  • -

#4 emaricela87  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 13-October 12

Re: How can I send an automatic "thankyou.html" upon pressing "

Posted 14 October 2012 - 11:42 AM

Thank you both, that fix my problem. You guys are awesome.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1