My first PHP script - what's wrong with it?

This is a discussion on "My first PHP script - what's wrong with it?" within the PHP Forum section. This forum, and the thread "My first PHP script - what's wrong with it? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jan 30th, 2006, 01:42
New Member
Join Date: Jan 2006
Age: 37
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question My first PHP script - what's wrong with it?

I just made my first PHP script, but there must be a mistake in it.
Could any of you please take a look at it and tell me what is wrong?
When the script executes it is supposed to send me an email with the information somebody filled out in a form on my website (first name, last name, zip code and email).
The thank you and error pages do show up when somebody tries to fill out the form, but I never get an email.
Any ideas for this newbie?
PHP: Select all

<?
$mailto 
"filled in my email address here" ;
 
$subject "newsletter sign up" ;
 
$formurl "http://my URL/newsletter.html;
$errorurl "http://my URL/newslettererror.html;
$thankyouurl "http://my URL/thankyounewsletter.html;
 
$first_name $_POST['first_name'] ;
$last_name $_POST['last_name'] ;
$zip_code $_POST['zip_code'] ;
$email $_POST['email'] ;
$http_referrer getenv"HTTP_REFERER" );
if (!isset(
$_POST['email'])) {
header"Location: $formurl" );
exit ;
}
if (empty(
$first_name) || empty($last_name) || empty($zip_code) || empty($email)) {
header"Location: $errorurl" );
exit ;
}
$first_name strtok$first_name"\r\n" );
$last_name strtok$last_name"\r\n" );
$zip_code strtok$zip_code"\r\n" );
$email strtok$email"\r\n" );
 
mail($mailto$subject);
header"Location: $thankyouurl" );
exit ;
?>
Reply With Quote

  #2 (permalink)  
Old Jan 30th, 2006, 01:53
Reputable Member
Join Date: Sep 2005
Location: Canada, BC
Age: 24
Posts: 239
Thanks: 0
Thanked 0 Times in 0 Posts
Re: My first PHP script - what's wrong with it?

mail is missing the third attribute which should be your message. I'm pretty sure that if you don't have it, the function fails.

Also, some ISP's block mails send via the php mail function >.<

you might want to try some error reporting with the mail function

ie
PHP: Select all

$check mail('email@you.com','subject','message);
if(!$check = '
Mail was not able to be sentplease contact webmaster.; 

Last edited by Pheonix; Jan 30th, 2006 at 01:56.
Reply With Quote
Reply

Tags
first, php, script, wrong

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone see what's wrong with this? Matty Brown PHP Forum 7 Sep 24th, 2007 07:26
Where am I going wrong? JamesQ Flash & Multimedia Forum 6 Jun 5th, 2007 15:05
What's wrong with this........? hart084 Web Page Design 5 Jan 31st, 2007 18:10
Login Script... something wrong! snowangel PHP Forum 6 Mar 6th, 2006 15:27
what is wrong-what do i do mdavid87 Classic ASP 4 Jun 3rd, 2005 09:15


All times are GMT. The time now is 20:51.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43