PDA

View Full Version : Mail Form



alexjewell
06-03-2007, 11:39 PM
I've never had trouble with mailing before, and I'm quite shocked that this wont work. I can't see anything wrong with the script, and no errors are being thrown back. The email just doesn't show up. Let me know if you see something wrong with the code:



<?php
$to = 'alexjewell@sbcglobal.net';

$fname = $_REQUEST['firstname'] or 'No First Name!';
$lname = $_REQUEST['lastname'] or 'No Last Name!';
$name = $fname.' '.$lname;

$address = $_REQUEST['address'] or 'No Address Submitted!';
$city = $_REQUEST['city'] or 'No City Submitted!';
$state = $_REQUEST['state'];

if(@$_REQUEST['zip']){
$zip = $_REQUEST['zip'];
if(ctype_digit($zip)){
$zip = $_REQUEST['zip'];}
else{$zip = 'Zip Submitted Not Valid!';}}
else{
$zip = 'No Zip Submitted!';}

if(@$_REQUEST['email']){
$email = $_REQUEST['email'];
if(!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $email)){
$email = $_REQUEST['email'];}
else{$email = 'Email Address Submitted Not Valid!';}}
else{
$email = 'No Email Address Submitted!';}

$comments = stripcslashes($_REQUEST['comments']) or 'No Comments Submitted';
$updates = $_REQUEST['updates'] or 'No, Thank You';

$subject = 'Partner Submission.';
$body = '
Name: '.$name.'
Address: '.$address.'
City: '.$city.'
State: '.$state.'
Zip: '.$zip.'
Email: '.$email.'
Comments: '.$comments.'
Updates: '.$updates;

if(mail($to,$subject,$body,$email)){ ?>
<h1>Thank You For Partnering!</h1>
<p>Your generous partnership is a blessing and God will bless you for it. Whether it's a commitment to pray or
give money, your gift is greatly appreciated.</p><br /><br />

<?php }

else{ ?>

<h1>There has been an error</h1>
<p>For some reason, your submission did not go through. You can try again by visiting the partnership page. If
it doesn't work again, please let me know by going to the contact page and sending me an email.</p><br /><br />

<?php } ?>

djr33
06-04-2007, 02:51 AM
Have you had success with other email scripts on this server?

alexjewell
06-04-2007, 12:14 PM
Yeah, I have. In fact, there's another mail form that's working at the same time on the server. Ha, makes no sense.

Twey
06-04-2007, 12:37 PM
Your generous partnership is a blessing and God will bless you for it.Presuming to know the minds of deities? :p

Are you certain you don't have any spam filters that could be deleting it?

alexjewell
06-04-2007, 02:15 PM
Haha, it's for a client who's a missionary.

And yes, I'm sure. I keep thinking maybe the emails are just getting delayed and will probably all show up tomorrow or something. Ha.

So basically, there's nothing wrong with the code itself that could be causing this?

thetestingsite
06-04-2007, 02:56 PM
From what I can tell, the code looks fine.

Twey
06-04-2007, 05:00 PM
Looks OK to me too.

There are lots of passages in the Bible saying how God and his thoughts are far beyond human comprehension :)

alexjewell
06-04-2007, 05:15 PM
Alright, well, I'll contact my host and ask them if they've recently changed something. I just tried my other mail form, and it isn't working either.

alexjewell
06-04-2007, 06:08 PM
I talked to some foreign customer service people, who didn't really seem to know what they were talking about. Anyway, what they said was I couldn't use PHP to send mail on windows servers and had to use ASP. What I don't understand is that PHP works for everything else on this server, so why would the mail function be the only thing not working because of the server being windows?

Also, the mail function worked up until recently anyway, but they claim they haven't made any changes. Well, neither have I.

Any ideas?

thetestingsite
06-04-2007, 06:14 PM
Simple answer, they (your host) don't know what they are talking about.

alexjewell
06-04-2007, 06:17 PM
Yeah. That's obvious. In fact, it says PHP under the Windows hosting: http://ucvhost.com/shared.htm

Ha, I really don't have the money to switch hosts right now either.

I'll have to host the one file somewhere else, then.

alexjewell
06-04-2007, 06:30 PM
Ok, the script is on a client's server and refreshes back to the site. This'll have to do.

This Indian customer service lady is sending me an asp script for mailing. It's possible to submit the php page to the asp page, yes?

Twey
06-04-2007, 06:35 PM
They haven't configured it correctly. On UNIX systems, where the sendmail program is installed, setting up PHP for mail is simple: just give it the path to the sendmail executable. On Windows, though, one must point it to an external SMTP server and give it an account.

djr33
06-04-2007, 07:13 PM
With godaddy hosting (what I use, just as an example, since I assume this is not your host), on my linux account PHP works without problems. On my windows account, it works well, too. The only difference is that mail() doesn't work on windows. Simple as that. Perhaps they can fix it.
I don't think they are suggesting that you must use ASP over PHP for all things, but that mail() won't work for PHP, so you should use an ASP email script instead. That's not going to do you much good, but maybe it's an option for a single page.

alexjewell
06-04-2007, 07:58 PM
Alright, thanks guys.

I may invest in my own server soon. It's the summer, I have time. I'll have the money soon enough. It would save this junk. Haha.

Twey
06-04-2007, 08:24 PM
For a normal web server, an ordinary PC will do. I even knew someone to set one up on a router. Connection speed is much more important. Note that with home ISPs, the up speed (which is more useful to a server) tends to be drastically smaller than the down speed.

alexjewell
06-05-2007, 12:04 AM
Well, I have dial up. That's the other issue. Haha.

We'll see. Thanks Twey.