# contact form, could anyone look it over not getting errors just not receiving the email



## Sean8 (Jan 9, 2014)

```
<?php

// Your Name
$your_name ="$your name";

// Mail of sender
$your_email="$your email";


// Phone Number
$phone_number="$phone number";


// Subject
$subject="$subject";

// Your Message
$your_message="$your message";


// Enter your email address
$to ='info@mydomain.com';

$send_contact=mail($your_name,$your_email,$phone_number,$subject,$your_message);


// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>



<table width="960" border="0" cellpadding="0">
  <tr>
  <td><form id="form1" name="form1" method="post" action="contact.php">
  <p>
  <label>Your Name (required)
  <br />
  <input type="text" name="your name" id="your name" />
  </label>
  </p>
  <p>
  <label>Your Email (required)
  <br />
  <input type="text" name="your email" id="your email" />
  </label>
  </p>
  <p>
  <label>Your Phone No.<br />
  <input type="text" name="phone number" id="phone number" />
  </label>
  </p>
  <p>
  <label>Subject<br />
  <input type="text" name="subject" id="subject" />
  </label>
  </p>
  <p>
  <label>Your Message<br />
  <textarea name="your message" id="your message" cols="65" rows="5"></textarea>
  </label>
  </p>
  <p>
  <input name="submit" type="submit" id="submit" onclick="MM_validateForm('your name','','R','your email','','R');return document.MM_returnValue" value="Submit" />
  </p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  </form></td>
  </tr>
</table>
```


----------



## Exceededgoku (Jan 9, 2014)

Looks to be fine unfortunately; What version of PHP is running on the server? Is there any firewall in place.

One thing I've noticed is that you change from double quotes to single quotes for the to address:

$to ='info@mydomain.com';


----------



## Sean8 (Jan 9, 2014)

Exceededgoku said:


> Looks to be fine unfortunately; What version of PHP is running on the server? Is there any firewall in place.
> 
> One thing I've noticed is that you change from double quotes to single quotes for the to address:
> 
> $to ='info@mydomain.com';


php 5.4.21

fixed the quote issue, changed the email address to send too also, same problem


----------



## Exceededgoku (Jan 9, 2014)

Oh and big no no is space in names for variables. Use underscore or dashes if you really want to keep words separated. <--- Ignore this, I read it wrong...

I'll put your code onto my website and see if it makes more sense in a HTML editor.

EDIT - Have a look at this example: http://www.freecontactform.com/email_form.php


----------



## Sean8 (Jan 9, 2014)

Exceededgoku said:


> Oh and big no no is space in names for variables. Use underscore or dashes if you really want to keep words separated. <--- Ignore this, I read it wrong...
> 
> I'll put your code onto my website and see if it makes more sense in a HTML editor.
> 
> EDIT - Have a look at this example: http://www.freecontactform.com/email_form.php


hopefully you will be able to find the problem,  i will look at that example.  It has something to do with sending i know that lol

im very new to php


----------



## hellrazor (Jan 10, 2014)

Use code tags next time.


----------



## Sean8 (Jan 10, 2014)

hellrazor said:


> Use code tags next time.


anything else you can contribute?

has anyone else had a chance to look over it to see what I'm missing?


----------



## Easy Rhino (Jan 10, 2014)

Sean8 said:


> anything else you can contribute?
> 
> has anyone else had a chance to look over it to see what I'm missing?



I am confused by the topic? So your form is fine. Your problem is you are not getting the email? Do you have an email server setup to send email????


----------



## Mindweaver (Jan 10, 2014)

Yea your form is fine. I'm with Easy Rhino do you have an email server setup? Also, you can test run php code online here. Paste your PHP code in and run code *in the future*. 

*EDIT: Forgot to add that last little part.. lol*


----------



## Solaris17 (Jan 11, 2014)

do you have sendmail enabled on your server?


----------



## silentbogo (Jan 11, 2014)

Did you check the Spam folder? Most of the time if email comes from the unknown source - it is automatically moved to the spam folder. Had a similar problem with email redirection for one of my customer's project.
Another major problem is that you mail it wrong.
The correct syntax for mail is:

```
bool mail ( string $to , string $subject , string $message [, string $additional_headers [,string $additional_parameters ]] )
```
.. so your "from" email is sent as a subject, phone # as the message and the actual message is considered an additional header for sendmail.
try it this way:

```
$to      = 'someone@mail.com';
$subject = 'subject';
$message = 'message';
$headers = 'From: me@example.com' . "\r\n" .
    'Reply-To: me@example.com';

if(mail($to, $subject, $message, $headers))
{
  echo "message sent!";
}
else echo"Error!!!";
?>
```


----------

