Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

PHP script error


  • Please log in to reply

#1
lil_cat_luver

lil_cat_luver

    Member

  • Member
  • PipPipPip
  • 296 posts
I'm using NL-PHPMail to power this little form here, and it's acting very strange. In my 2 years of using this script, this has never happened before, but now for some unknown reason, it tells me the required fields are missing even though they were all filled out :tazz:

In addition, the radio buttons and checkboxes' values are not showing up...

Maybe someone can take a look here. Any help is appreciated :)
<?php 
#
# NL-PHPMail v1.5
# Copyright 2002-2003 Sasha, http://nothing-less.net. All rights reserved.
# First released December 11, 2002
# This version released October 6, 2003
#
# NL-PHPMail v1.5 is linkware and can be used or modified as long as this note remains intact
# and unaltered, and there is a link up back to http://codegrrl.com/ so people know where you got this script. You are forbidden to sell or distribute the code of NL-PHPMail v1.5, in whole
# or part, without the written consent of Sasha.
#
# By using NL-PHPMail v1.5 you agree to indemnify Sasha from any liability.
#
# Website: 	http://codegrrl.com/scripts/phpmail/
# FAQ: 			http://codegrrl.com/faq/
# Support:	http://forums.codegrrl.com/
#

// -----------------------
//VARIABLES NEEDED FOR THE SCRIPT TO WORK, PLEASE CHANGE THESE AS SPECIFIED
// -----------------------

//Your email address (where the form will be sent):
$recipient = 'ragdoll030708@gmail.com';

//The subject of the email:
$subject = 'Request';

//Change this to the URL to your HTML form.
$form_url = 'http://etcetera-graphics.t35.com/request/request.php';

//If you're using Headers and Footers with PHP, please fill in the path to them below. This can be a relative path (like, header.inc if it's in the same directory), or an absolute path. If you're NOT using headers, please leave this empty.
$header ='header.php';
$footer ='footer.php';

//Below is the content of the actual email sent to you. If you have different or more form fields than specified here, copy and paste the below line (without the // in front of it) into the coding bit below. Beneath the Comments line would be a good place for it:
// $msg .= "Field Description: $_POST[field_name]\n";
// Change the description and field name to match the field in your form. The $_POST[field_name] variable is what takes the contents of the form fields, so change "field_name" to the name of your form field. The . in front of the = sign merely means that line will be added to the variable, along with all previous lines, instead of overwriting it, so don't take it out! Use \t to insert a tab, and \n to insert a new line.

$msg = "---------------\n";
$msg .= "$subject\n";
$msg .= "---------------\n\n";
$msg .= "Name: $_POST[name]\n";
$msg .= "Email: $_POST[email]\n";
$msg .= "Website: $_POST[url]\n";
$msg .= "Type: $_POST[type]\n";
$msg .= "Description: $_POST[description]\n";
$msg .= "Sender IP Address: $REMOTE_ADDR\n";

// Change the names below to the 3 required fields in your form. If these fields are not filled out, the script will not send an email and display an error message instead, asking the visitor to fill out the form again.
$req1 ="$name";
$req2 ="$email";
$req3 ="$description";

//The below error message will be displayed if not all required fields are filled in. Feel free to use normal HTML in this.
$error_required = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">It appears you forgot to enter either your <b>email address</b>, your <b>name</b> or a <b>description</b>. Please press the BACK button in your browser and try again. If you are receiving this message by mistake, please contact me <a href="mailto:ragdoll030708@gmail.com">here</a>.</p>';

//The below error message will be displayed if the visitor submitted an invalid email address. Feel free to use normal HTML in this.
$error_email = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">It appears that the email address you provided is not valid. Please press the back button on your browser and try again. Please check carefully that you filled in all information in the right fields. If you are receiving this message by mistake, please contact me <a href="mailto:ragdoll030708@gmail.com">here</a>.</p>';

//The below success message will be displayed when the form is sent. Feel free to use normal HTML in this.
$success_message = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">Your request has been sent, I will reply as soon as possible.</p>';

// -----------------------
//DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!
// -----------------------

if ($header ==""){
	$use_headers ='0';
	$header = '<html><head><title>Request Form</title></head><body>'; 
	} else {$use_headers ='1';}
if ($footer ==""){
	$use_footers ='0';
	$footer = '<div align="center"><a href="http://codegrrl.com/" target="_blank">Powered by NL-PHPMail</a></div></body></html>'; 
	} else {$use_footers ='1';}

function is_valid_email ($address) { 
	return (preg_match( 
		'/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+'.
		'@'. 
		'([-0-9A-Z]+\.)+' .   
		'([0-9A-Z]){2,4}$/i', 
		trim($address))); 
} 
function is_valid_email_eregi ($address) { 
	return (eregi( 
		'^[-!#$%&\'*+\\./0-9=?A-Z^_`{|}~]+'.  
		'@'.	  
		'([-0-9A-Z]+\.)+' .   
		'([0-9A-Z]){2,4}$',   
		trim($address))); 
} 

if (!isset($req1) || !isset($req2) || !isset($req3)) {
	header( "Location: $form_url" ); }

  elseif (empty($req1) || empty($req2) || empty($req3)) {
	
		if ($use_headers =="0"){
		echo "$header";
		} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_required?>


<?
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
  }
  else {

$f_email = $_POST[email];
$f_email = strtolower(trim($f_email)); 
	if (is_valid_email($f_email)) { 
$msg .= "\n\n---------------\n";
$msg .= "NL-PHPMail v1.5 - http://codegrrl.com/\n";
$msg .= "---------------\n\n";

$mailheaders = "MIME-Version: 1.0 \n"; 
	$mailheaders .= "Content-type: text/plain; charset=iso-8859-1 \n"; 
	$mailheaders .= "From: \"$_POST[email]\" <$_POST[email]> \n"; 
	$mailheaders .= "Reply-To: \"$_POST[email]\" <$_POST[email]> \n"; 
	$mailheaders .= "X-Priority: 3 \n"; 
	$mailheaders .= "X-MSMail-Priority: High \n"; 
	$mailheaders .= "X-Mailer: PHP4";

mail($recipient, $subject, $msg, $mailheaders);

	if ($use_headers =="0"){
		echo "$header";
		} else { include ("$header"); }
?>
<h2>Thank You<?=$name?></h2>
<?=$success_message?>

<?  
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
}  else {
		if ($use_headers =="0"){
			echo "$header";
			} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_email?>
<?
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
} } ?>


Edited by lil_cat_luver, 23 December 2005 - 04:14 AM.

  • 0

Advertisements


#2
gerryf

gerryf

    Retired Staff

  • Retired Staff
  • 11,365 posts
Before getting into the actual code, did you host update PHP to a newer version?

Scripts that magically stop working generally do so because the host updates something on their end and your script is no longer compatible
  • 0

#3
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
No, actually, when I used it before, I used it on a different website.
  • 0

#4
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
it looks like it consists of two PHP seperate files. Could you post the second one?
  • 0

#5
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
I have checked my files and the script website, this is the only PHP file :tazz:
  • 0

#6
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
OK, I am not exactly sure if it will work, but try this out. Replace that code you posted with this one. Tell me your results a.s.a.p. :tazz:

<?php 
#
# NL-PHPMail v1.5
# Copyright 2002-2003 Sasha, http://nothing-less.net. All rights reserved.
# First released December 11, 2002
# This version released October 6, 2003
#
# NL-PHPMail v1.5 is linkware and can be used or modified as long as this note remains intact
# and unaltered, and there is a link up back to http://codegrrl.com/ so people know where you got this script. You are forbidden to sell or distribute the code of NL-PHPMail v1.5, in whole
# or part, without the written consent of Sasha.
#
# By using NL-PHPMail v1.5 you agree to indemnify Sasha from any liability.
#
# Website:	 http://codegrrl.com/scripts/phpmail/
# FAQ:			 http://codegrrl.com/faq/
# Support:	http://forums.codegrrl.com/
#

// -----------------------
//VARIABLES NEEDED FOR THE SCRIPT TO WORK, PLEASE CHANGE THESE AS SPECIFIED
// -----------------------

//Your email address (where the form will be sent):
$recipient = 'ragdoll030708@gmail.com';

//The subject of the email:
$subject = 'Request';

//Change this to the URL to your HTML form.
$form_url = 'http://etcetera-graphics.t35.com/request/request.php';

//If you're using Headers and Footers with PHP, please fill in the path to them below. This can be a relative path (like, header.inc if it's in the same directory), or an absolute path. If you're NOT using headers, please leave this empty.
$header ='header.php';
$footer ='footer.php';

//Below is the content of the actual email sent to you. If you have different or more form fields than specified here, copy and paste the below line (without the // in front of it) into the coding bit below. Beneath the Comments line would be a good place for it:
// $msg .= "Field Description: $_POST[field_name]\n";
// Change the description and field name to match the field in your form. The $_POST[field_name] variable is what takes the contents of the form fields, so change "field_name" to the name of your form field. The . in front of the = sign merely means that line will be added to the variable, along with all previous lines, instead of overwriting it, so don't take it out! Use \t to insert a tab, and \n to insert a new line.

$msg = "---------------\n";
$msg .= "$subject\n";
$msg .= "---------------\n\n";
$msg .= "Name: $_POST[name]\n";
$msg .= "Email: $_POST[email]\n";
$msg .= "Website: $_POST[url]\n";
$msg .= "Type: $_POST[type]\n";
$msg .= "Description: $_POST[description]\n";
$msg .= "Sender IP Address: $REMOTE_ADDR\n";

// Change the names below to the 3 required fields in your form. If these fields are not filled out, the script will not send an email and display an error message instead, asking the visitor to fill out the form again.
$req1 ="$_POST[name]";
$req2 ="$_POST[email]";
$req3 ="$_POST[description]";

//The below error message will be displayed if not all required fields are filled in. Feel free to use normal HTML in this.
$error_required = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">It appears you forgot to enter either your <b>email address</b>, your <b>name</b> or a <b>description</b>. Please press the BACK button in your browser and try again. If you are receiving this message by mistake, please contact me <a href="mailto:ragdoll030708@gmail.com">here</a>.</p>';

//The below error message will be displayed if the visitor submitted an invalid email address. Feel free to use normal HTML in this.
$error_email = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">It appears that the email address you provided is not valid. Please press the back button on your browser and try again. Please check carefully that you filled in all information in the right fields. If you are receiving this message by mistake, please contact me <a href="mailto:ragdoll030708@gmail.com">here</a>.</p>';

//The below success message will be displayed when the form is sent. Feel free to use normal HTML in this.
$success_message = '<link rel="stylesheet" href="style.css" type="text/css" /><p align="justify">Your request has been sent, I will reply as soon as possible.</p>';

// -----------------------
//DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU'RE DOING!!
// -----------------------

if ($header ==""){
	$use_headers ='0';
	$header = '<html><head><title>Request Form</title></head><body>'; 
	} else {$use_headers ='1';}
if ($footer ==""){
	$use_footers ='0';
	$footer = '<div align="center"><a href="http://codegrrl.com/" target="_blank">Powered by NL-PHPMail</a></div></body></html>'; 
	} else {$use_footers ='1';}

function is_valid_email ($address) { 
	return (preg_match( 
		'/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+'.
		'@'. 
		'([-0-9A-Z]+\.)+' .   
		'([0-9A-Z]){2,4}$/i', 
		trim($address))); 
} 
function is_valid_email_eregi ($address) { 
	return (eregi( 
		'^[-!#$%&\'*+\\./0-9=?A-Z^_`{|}~]+'.  
		'@'.	  
		'([-0-9A-Z]+\.)+' .   
		'([0-9A-Z]){2,4}$',   
		trim($address))); 
} 

if (!isset($req1) || !isset($req2) || !isset($req3)) {
	header( "Location: $form_url" ); }

  elseif (empty($req1) || empty($req2) || empty($req3)) {
	
		if ($use_headers =="0"){
		echo "$header";
		} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_required?>


<?
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
  }
  else {

$f_email = $_POST[email];
$f_email = strtolower(trim($f_email)); 
	if (is_valid_email($f_email)) { 
$msg .= "\n\n---------------\n";
$msg .= "NL-PHPMail v1.5 - http://codegrrl.com/\n";
$msg .= "---------------\n\n";

$mailheaders = "MIME-Version: 1.0 \n"; 
	$mailheaders .= "Content-type: text/plain; charset=iso-8859-1 \n"; 
	$mailheaders .= "From: \"$_POST[email]\" <$_POST[email]> \n"; 
	$mailheaders .= "Reply-To: \"$_POST[email]\" <$_POST[email]> \n"; 
	$mailheaders .= "X-Priority: 3 \n"; 
	$mailheaders .= "X-MSMail-Priority: High \n"; 
	$mailheaders .= "X-Mailer: PHP4";

mail($recipient, $subject, $msg, $mailheaders);

	if ($use_headers =="0"){
		echo "$header";
		} else { include ("$header"); }
?>
<h2>Thank You<?=$name?></h2>
<?=$success_message?>

<?  
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
}  else {
		if ($use_headers =="0"){
			echo "$header";
			} else { include ("$header"); }
?>
<h2>Error</h2>
<?=$error_email?>
<?
		if ($use_footers =="0"){
		echo "$footer";
		} else { include ("$footer"); }
} } ?>

  • 0

#7
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
Thanks :tazz: I'll try that asap
  • 0

#8
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
So, did it work? I am interested too, because I am not sure if the error is there where I corrected it. :tazz:
  • 0

#9
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
It kind of works (it says sent) but I never actually get the email...
  • 0

#10
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Check the mail settings of your webhosting, may be it's just because they don't support it.
  • 0

#11
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
Hmm, I'm not sure about that, but they say they support PHP...
  • 0

#12
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
Well, they could support PHP, but the mail settings could be slightly strange :)

replace this:
mail($recipient, $subject, $msg, $mailheaders);

with this:

if (mail($recipient, $subject, $msg, $mailheaders)) echo "Success";
else echo "Failure";

Tell me the results. :tazz:
  • 0

#13
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
OK, thanks. I'll try that asap. It'll probably be a while before I could do that :tazz: , but I will post the results :)
  • 0

#14
lil_cat_luver

lil_cat_luver

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 296 posts
I''ve decided to move my site to a new host, so I don't think I will have this problem anymore. Thank you so much Hai Mac for all your help, I really appreciate it :tazz:
  • 0

#15
Hai Mac

Hai Mac

    Member

  • Member
  • PipPipPip
  • 260 posts
You're welcome. By the way, I like your site, so when you've finished moving, tell me the new domain :tazz:
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP