Re: Undefined Variable

From: Date: Sat, 14 Dec 2002 21:00:32 +0000
Subject: Re: Undefined Variable
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-128299@lists.php.net to get a copy of this message
Hey Anthony-- It's definitely a register_globals problem. Your ISP has turned it off because it's generally considered a significant security risk. The best way to solve it is to use the superglobal $_POST to access your post data. In your PHP script, change all the variables that you take from the form into their $_POST[''] equivalent (see below for a rough example--I put the assignments at the beginning because I wanted to touch your code as little as possible). Also, keep in mind that you're not performing any checks on the data--I'm sure you want to do it once you've sorted the current problem out, but the way it is now you're leaving yourself exposed to a number of possible attacks. $thename = $_POST['thename']; $email = $_POST['email']; $description = $_POST['description']; $bizname = $_POST['bizname']; $contactname = $_POST['contactname']; $phone = $_POST['phone']; $email = $_POST['email']; $mailing = $_POST['mailing']; $town = $_POST['town']; $state = $_POST['state']; $zip = $_POST['zip']; $cat = $_POST['cat']; if (($thename == "") && ($email == "") && ($description == "")) { header("Location: http://localhost/n_proserv_x.html"); exit; } $msg = "This e-mail was sent from:\n"; $msg .= "Sender's Name: $thename\n"; $msg .= $thename ."'s business name is: $bizname\n"; $msg .= "The contact person is: $contactname\n"; $msg .= $thename. "'s phone number is: $phone\n"; $msg .= $thename. "'s e-mail address is: $email\n"; $msg .= $thename. "'s mailing address is: $mailing\n"; $msg .= "Town: $town\n"; $msg .= "State: $state\n"; $msg .= "Zip Code: $zip\n"; $msg .= $thename."'s category is: $cat\n"; $msg .= "and the message is: $description\n\n"; $to = "tony@gonefishingguideservice.com"; $subject = "Narrowsburg Chamber of Commerce"; $mailheaders = "From: $thename\n"; $mailheaders .= "Reply to:$email\n\n"; mail($to, $subject, $msg, $mailheaders); ?> -- ------------ php|architect - The Magazine for PHP Professionals The monthly magazine dedicated to the world of PHP programming Check us out on the web at http://www.phparch.com!

« previous php.general (#128299) next »