Having problems with php mail

Hello,

I’m new here, I’ve been into php for a few years now but only managed to have time to get back into it

i’m after having an enquiry form on my website so people can fill it in and i’ll get it sent to my email address

but the problem is, i can’t use strings and vars together

[php]<?php
if(!isset($_POST[‘postenquiry’])){
$content = 'If you would like to recieve a quote, then feel free to fill in this short form and we will get back to you as soon as possible.

<tr>

  <td width="103" scope="col">Name:</td>

  <th width="287" scope="col"><label for="name"></label>

      <input type="text" name="name" id="name" />
</th>

</tr>

<tr>

  <td>Number:</td>

  <td><label for="number"></label>

      <input type="text" name="number" id="number" /></td>

</tr>

<tr>

  <td>Location:</td>

  <td><label for="location"></label>

      <input type="text" name="location" id="location" /></td>

</tr>

<tr>

  <td>Message:</td>

  <td><label for="message"></label>

      <textarea name="message" cols="35" rows="5"></textarea></td>

</tr>

<tr>

  <td></td>

  <td>

    <input type="submit" name="postenquiry" id="postenquiry" value="Submit" />

  </form></td>

</tr>
'; echo $content; }else{ $email = "[email protected]"; $headers = "From: [email protected]"; $subject = $_POST['name']; $location = $_POST['location']; $message = "This is your message: ".$_POST['message'].""; $number = $_POST['number']; mail($email,$subject,$message,$headers); $content = 'Done'; echo $content; echo $message; } ?>[/php]

the email sends just with data that’s in the message field, and not the string before it.

i’m also after doing the same thing with the subject of the email but it just gets info from the name field, even if i remove the $_POST[‘name’] from the “$subject” var

Any idea on whats wrong here?

Thank you guys

Well initially the only thing I see is that your ending form tag needs to be moved to outside the ending table tag. Also you define $location and $number but you don’t seem to do anything with them.

Thanks for the reply

I’ve sorted it now, it was the quotes of starting the variable “$var = “string”;” instead of ’

the php code is inside a div tag which is css styled, thank you for your reply anyway :slight_smile:

Glad you figured it out but what I said before is still important cause if you view the source in the browser you’ll see that it throws errors cause you have those end tags in the wrong place.

Sponsor our Newsletter | Privacy Policy | Terms of Service