Jump to content

PHP Form - Keeping Values


beaner_06

Recommended Posts

Hello, I have attached my code I am working with. The form is calling itself and after submission, the form should keep the values that the user had entered and then display the result of the commission amount. I'm not sure where I am going wrong, but the form submits and it displays the GET information in the URL, but nothing shows up. Any help is appreciated.

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Commission</title>
</head>
<body>
<h1>Commission Computation</h1>

<form method="get" action='rlbSinglePreserve.php'>
<?php
//Form should keep values entered by user after submission
if(isset($_GET["strSale"])) 
{
	$strSale = $_GET["sale"];
	$lboRegion = $_GET["Region"];

	echo "Monthy Sale: <input name='sale' type='text' value='$strSale' /><br/><br/>";
	echo "Select your Sales Region:";
	echo "<select name='Region' size='4' style='height:38px;'>";
	echo "<option name='eastern'>Eastern</option>";
	echo "<option name='western'>Western</option>";
	echo "</select><br/><br/>";
	echo "<input type='submit' value='Show Commission'/>";

	//Depending on region will decide amount of commission that person receives
		switch ($lboRegion)
		{
			Case "Eastern":
				$commission = $strSale * 0.1;
				break;
			Case "Western":
				$commission = $strSale * 0.2;
				break;
		}

	echo "Your Commission is: $$commission ";
}

else 
{
	echo "Monthy Sale: <input name='sale' type='text'/><br/><br/>";
	echo "Select your Sales Region:";
	echo "<select name='Region' size='4' style='height:38px;'>";
	echo "<option name='eastern'>Eastern</option>";
	echo "<option name='western'>Western</option>";
	echo "</select><br/><br/>";
	echo "<input type='submit' value='Show Commission'/>";
}
?>
</form>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.