Page 2 of 2

Posted: Thu Sep 14, 2006 6:15 pm
by gkwhitworth
I ended up making some large changes to how the form worked last night, the errors are still the same but they are on different numbers...so here is the entire php code on the page: http://www.gkwinspired.com/contact/web2.php (you can view it if you want...it works pretty good except for the undefined index problems)

Anyways....here is the code:

Code: Select all

<?php
					if (!isset ($_REQUEST['package'])){
					$answer = 0;
					}
					
					if (!isset ($_REQUEST['flash']) && ($_REQUEST['phpForm']) && ($_REQUEST['asp']) && ($_REQUEST['cms'])) {
					$answer = 0;
					}
					
					if (!isset ($_REQUEST['fname']) || ($_REQUEST['lname']) || ($_REQUEST['email']) || ($_REQUEST['phone']) || ($_REQUEST['address']) || ($_REQUEST['city'])
					|| ($_REQUEST['zip']) || ($_REQUEST['flash']) || ($_REQUEST['phpForm']) || ($_REQUEST['asp']) || ($_REQUEST['cms'])) {
					echo "Thank you for your interest in a GKW Website.  Please fill out the form below to get an estimate for your website.";
					}
							
						$fname = $_REQUEST['fname'];
						$lname = $_REQUEST['lname'];
						$email = $_REQUEST['email'];
						$phone = $_REQUEST['phone'];
						$address = $_REQUEST['address'];
						$city = $_REQUEST['city'];
						$state = $_REQUEST['state'];
						$zip = $_REQUEST['zip'];
						$package = $_REQUEST['package'];
						$packagePrices = array (
								'Basic' => 1500,
								'Professional Lite' => 2300,
								'Premium Professional' => 3500
								);												
						$flash = $_REQUEST['flash'];
						$flashPrice = 500;
						$phpForm = $_REQUEST['phpForm'];
						$phpPrices = array (
								'1' => 200,
								'2' => 400,
								'3' => 600,
								'4' => 800,
								'5' => 1000
								);
						$asp = $_REQUEST['asp'];
						$aspPrice = 1500;
						$cms = $_REQUEST['cms'];
						$cmsPrice = 3000;
																				
												
						?>
As you can tell I took out the code that feyd wrote....mainly because I was implementing it wrong...if you can give an example...that would be great. I searched for the function 'pullElement' but then read in a book that that is the function name, and you can name it whatever you want.

Thanks everah...you and feyd have been a great help.

--
Greg

Posted: Thu Sep 14, 2006 6:40 pm
by RobertGonzalez
You are still using $_REQUEST instead of $_POST. As for the isset() checks, you might want to consider looping the $_POST array to see if the items are set (actually you can assign from there).

Posted: Thu Sep 14, 2006 8:27 pm
by gkwhitworth
I switched them to POST for a while, but then I tried using feyd's code and in troubleshooting mode I switched them back to REQUEST to see if that mattered. Uhm.......... ok........... then...........I will search about how to loop my array. Thanks, I will post back my further problems

Posted: Thu Sep 14, 2006 8:54 pm
by gkwhitworth
Ok, ok....I searched for a while and have found that looping is known as foreach or for etc. I need to know how you meant to loop it. At least point me in the right direction...you don't have to do the work for me.

--
Greg

Posted: Fri Sep 15, 2006 11:07 am
by RobertGonzalez
Okay, this is not a preffered way of doing it, but it is a quick hack...

Code: Select all

<?php
foreach ($_POST as $key => $value)
{
    if (empty($value))
    {
        echo '<p>The posted field named ' . $key . ' is showing an empty value.</p>';
    }
}
?>

Posted: Fri Sep 15, 2006 2:14 pm
by gkwhitworth
<?php
foreach ($_POST as $key => $value)
{
if (empty($value))
{
echo '<p>The posted field named ' . $key . ' is showing an empty value.</p>';
}
}
?>
This part:
foreach ($_POST as $key => $value)
Did you just tell _POST to be known as $key and then key to be known as $value through an array?

--
Greg

Posted: Fri Sep 15, 2006 2:15 pm
by feyd
read up on how foreach works. ;)

k

Posted: Fri Sep 15, 2006 2:42 pm
by gkwhitworth
will do...