Ok, Folks.... Just trying to clean up some free php code I recently garnered :-) It came complete with a COMMENTS box, yet I really don't need it. Can anyone show me what needs to be deleted in order for the PHP form to continue working properly? I tried deleting what I thought should be deleted yet I keep getting my ERROR.html page sent back to me. Of course, when I input some text in the COMMENTS area, the form submits properly, followed by the Thank You page.

I know how to take out the COMMENTS box in my HTML code, yet the PHP is not as easy. Any suggestions?

Keith/Zen!

any chance you can post the code?

I suspect there's somewhere that fetches the form parameter for the comment and if it's empty redirects the user to error.html

any chance you can post the code?

Ok... if I'm doing this right, here's what I got as the code

$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
	header( "Location: $formurl" );
	exit ;
}
if (empty($name) || empty($email) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
	header( "Location: $errorurl" );
	exit ;
}

if (get_magic_quotes_gpc()) {
	$comments = stripslashes( $comments );
}

$messageproper =

	"This message was sent from:\n" .
	"$http_referrer\n" .
	"------------------------------------------------------------\n" .
	"Name of sender: $name\n" .
	"Email of sender: $email\n" . 
	"------------------------- COMMENTS -------------------------\n\n" .
	$comments .
	"\n\n------------------------------------------------------------\n" ;

There it is... Now, If I might ask... which parts of the code should I erase that will still allow the form to work minus the COMMENTS box? I do not want the COMMENTS box. Thanks!

Zen!

replace this one:

#
$messageproper =
#
 
#
"This message was sent from:\n" .
#
"$http_referrer\n" .
#
"------------------------------------------------------------\n" .
#
"Name of sender: $name\n" .
#
"Email of sender: $email\n" .
#
"------------------------- COMMENTS -------------------------\n\n" .
#
$comments .
#
"\n\n------------------------------------------------------------\n" ;

with:

$messageproper ="";
if (empty($name) || empty($email) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}

change the above code (starts on line 11) so that it looks like this:

if (empty($name) || empty($email)) {
   header( "Location: $errorurl" );
   exit ;
}

that way, it won't require the comments to be filled anymore. If you want to allow the user to also leave the name and email fields blank, you can just get rid of that entire block of code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.