• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

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

Joined
Mar 7, 2009
Messages
299 (0.05/day)
System Name Build 1
Processor i5 2500k
Motherboard Asus P8Z68-V PRO/GEN3
Cooling Cooler Master 212
Memory Corsair DDR3 1600
Video Card(s) onboard
Power Supply Corsair AX750
Software Windows 7 Professional
PHP:
<?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>
 
Last edited by a moderator:
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';
 
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
 
Last edited:
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
 
Last edited:
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
 
Use code tags next time.
 
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?
 
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????
 
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. :toast:

EDIT: Forgot to add that last little part.. lol
 
Last edited:
do you have sendmail enabled on your server?
 
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:
PHP:
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:
PHP:
$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!!!";
?>
 
Back
Top