0

I am currently working on a simple form and i want the info to be collected by a php script and then sent to me as a mail, but i am not receiving the specific email.

Could anybody give any pointers or highlight the problem? thank you

Here is the code for my form:

<form name="bookingForm" method="post" action="send_dates.php">
<table border="0" cellspacing="1" cellpadding="2">

<tr>
    <td>Booking From</td>
        <td>:</td>
    <td><input name="fromDate" id="fromDate" size="20"></td>

    <td>To</td>
    <td>:</td>
    <td><input name="toDate" id="toDate" size="20"></td>
</tr>

<tr>
    <td>Name</td>
    <td>:</td>
    <td><input name="name" type="text" id="name" size="30"></td>
</tr>

<tr>
    <td width="20px">Telephone</td>
    <td>:</td>
    <td><input name="telephone" type="text" id="customer_telephone" size="30"></td>
</tr>

<tr>
    <td width="20px">Email</td>
    <td>:</td>
    <td><input name="customer_mail" type="text" id="customer_mail" size="30"></td>
</tr>

<tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td><input type="submit" name="submit" value="Submit"> <input type="reset" name="ResetForm" value="Reset"></td>
</tr>
</table>
</form>

And here is my php script:

<?php 

 $name = $_POST['name'];
 $fromDate = $_POST['fromDate'];
 $toDate = $_POST['toDate');
 $email = $_POST['customer_email'];
 $telephone = $_POST['customer_telephone'];

// Mail of reciever
$to = "[email protected]";

// Contact subject
$subject ="Reservation Enquiry from $name";

// Details
$message="From: $name
Email: $email
Telephone: $customer_telephone
--------------------------------------------------------------
Reservation date from: $fromDate to: $toDate ";

// Mail of sender
$mail_from="$customer_mail";

// From

$res=mail($to,$subject,$message);
    if($res)
{
    header('Location:index.php');
}

    ?>
5
  • i just noticed this now but apparently there is a parse error: Parse error: syntax error, unexpected T_VARIABLE in /home/content/51/8418351/html/bofu/send_dates.php on line 20 it is this line: $subject ="Reservation Enquiry from $name"; Commented Jul 26, 2012 at 10:23
  • Did you check your spam mail? Commented Jul 26, 2012 at 10:24
  • do you have the correct SMTP server address in PHP.INI? Commented Jul 26, 2012 at 10:25
  • i dont know if i have the correct smtp server address... Commented Jul 26, 2012 at 10:28
  • Also your attempts are from localhost or from a production system? If you are working from localhost this article might help you Commented Jul 26, 2012 at 10:28

2 Answers 2

1

Semicolon missing

$to = "[email protected]";

UPDATE:

Remove if(!empty($data)) loop

Check for $res = mail(...);

Then put

if($res)
         {
            echo '<script type="text/javascript">
                     window.location = "index.php";
                  </script>';
         }
         else
         {
             echo 'something wrong';
         }
Sign up to request clarification or add additional context in comments.

6 Comments

how embarrassing. i just corrected this and now it echoes "something is wrong" meaning that the data is not being collected from the form
Didn't notice that. Where is $data defined?
thanks, instead of echoing mail sent how can i make the page refresh itself?
header('Location:index.php');
Edited answer. Please try again.
|
1

Possible cause is a wrong SMTP server address.

Stop the webserver, correct the SMTP server address in PHP.INI, restart the webserver.

You can check the current configuration by executing <?php phpinfo(); ?> and to search for SMTP.

2 Comments

in what should i change the smtp server address? currently it is relay-hosting.secureserver.net ? thank you
If your webserver is running local, you need to set the SMTP address. If you're using an online hosting, then this is already set to the correct server for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.