...

View Full Version : My Form works for all sites, BUT NOT THIS ONE! Why?



desmintaylor
09-06-2012, 04:13 AM
I am beyond frustrated. I coded a contact form that submits to my email address when the submit button is pressed. I used it on multiple sites for my clients, but for this one client's site, it just won't send!

I know the code has to be fine because I copied and pasted it from my site and tested it through many others I built. Now when I try and test the form, it doesn't submit to my email address.

The client purchased her domain and hosting through namecheap. I think it has something to do with namecheap, but that sounds silly because a host/domain provider should not effect my code. I have no clue what is causing this. The only difference between the site I am coding now and the ones I coded before is this one is a .org rather than .com or .net.

Someone please help me! I tried namecheap "customer support" three times and spent over four hours getting slow unhelpful responses from them.

Here is my code, if someone can help or find an alternate method for me, I'd appreciate it.



<?php
$to = "myemail@emails.com";
$subject = "GHoops Registration Form";
$fname = $_REQUEST['fname'] ;
$lname = $_REQUEST['lname'] ;
$school = $_REQUEST['school'] ;
$grade = $_REQUEST['grade'] ;
$coach = $_REQUEST['coach'] ;
$address = $_REQUEST['address'] ;
$city = $_REQUEST['city'] ;
$state = $_REQUEST['state'] ;
$zipcode = $_REQUEST['zipcode'] ;
$phone = $_REQUEST['phone'] ;
$email = $_REQUEST['email'] ;
$dob = $_REQUEST['dob'] ;
$height = $_REQUEST['height'] ;
$shirt = $_REQUEST['shirt'];
$PG = $_REQUEST['PG'] ;
$SG = $_REQUEST['SG'] ;
$SF = $_REQUEST['SF'] ;
$F = $_REQUEST['F'] ;
$C = $_REQUEST['C'] ;
$parentname = $_REQUEST['parentname'] ;
$contactnumber = $_REQUEST['contactnumber'] ;
$parentemail = $_REQUEST['parentemail'] ;
$choice = $_REQUEST['choice'] ;
$message1 = $_REQUEST['message1'] ;
$message2 = $_REQUEST['message2'] ;
$signature = $_REQUEST['signature'] ;
$date = $_REQUEST['date'] ;


$headers = "From: $fname $lname";

$message = <<< END
First Name: $fname
Last Name: $lname
School: $school
Grade: $grade
Coach: $coach
Address: $address
City: $city
State: $state
Zip Code: $zipcode
Phone Number: $phone
Email Address: $email
Date of Birth: $dob
Height: $height
Position: $PG $SG $SF $F $C
Parent Name: $parentname
Is Parent Primary Contact?: $choice
Primary Contact's Information: $message1
Medical History: $message2
Signature: $signature
Date: $date
END;

$sent = mail($to, $subject, $message, $headers) ;
?>


Thanks.

mlseim
09-06-2012, 04:45 AM
When you encounter problems like yours, always take a step back
and try a super simple test script, without all the fluff.

Save the script below as, "email_test.php" and put in your real email address.



<?php

// do a super simple email test ....

// put your real email address here
$to="johndoe@aol.com";

$sender="billsmith@comcast.com";
$subject="This is a test";
$message="This is the message content";
$headers = "From: $sender\r\nReply-To: $sender\r\n";

if(mail($to, $subject, $message, $headers)){
echo "email sent";
}

?>



You'll notice the mail() function is placed inside of an "if" statement. That is deliberate.
PHP will not continue on with the script until the mail function is complete.
The reason why is, PHP needs to determine if the "if" statement is true or false.
That forces the mail() function to finish without the possibility of the script
executing ahead and timing out.

$_REQUEST might be deprecated in your script. I'm not sure if the latest PHP versions use $_REQUEST?
You should be using $_GET or $_POST (most likely $_POST).

desmintaylor
09-06-2012, 05:27 AM
Okay. I ran the test script and it works. I will try and make the changes suggested and post the results. Thanks for responding. This is really a great forum!

mlseim
09-06-2012, 12:30 PM
One other thing ...

If you run PHP scripts, especially for testing, make sure error_reporting is enabled.

In your script example, you don't echo a line saying it worked. If your script actually
had a fatal error, you would get a blank white screen without an error message if
your error reporting is not enabled. So, you don't know if it worked or not.

If you have error-reporting enabled, it would display the error and line number.

http://php.net/manual/en/function.error-reporting.php



.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum