Hide PHP script until User Submits Data

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beaner_06
Forum Newbie
Posts: 13
Joined: Tue May 19, 2009 6:11 pm

Hide PHP script until User Submits Data

Post by beaner_06 »

Hello, I have attached my code. How would I delay the message: "Your Commission is: $_____" until the user actually enters an amount and hits the 'Show Commission' button? Thanks in advance.

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Commission</title>
</head>
<body>
 
<h1>Commission Computation</h1>
 
    <form method="get" action='rlbSingleGet.php'>
    Monthy Sale: <input name='sale' type='text' />
        <br />
        <br />
    Select your Sales Region:
        <select name='Region' size='4' style='height:38px;'>
            <option name='eastern'>Eastern</option>
            <option name='western'>Western</option>
        </select>
        <br />
        <br />
        <input type='submit' value='Show Commission'/>
    </form>
 
    <?php
            $strSale = $_GET["sale"];
            $lboRegion = $_GET["Region"];
            
            //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 "<h2>Your Commission is: ";
            // The following lines are only for documenting the PHP number_format and money_format
            // functions that do not work in Windows.  To display money formatted values in Windows and PHP,
            // we will have to use the following type of code:
            setlocale(LC_ALL, ''); // Locale will be different on each system.
            $locale = localeconv();
            echo $locale['currency_symbol'], number_format($commission, 2, $locale['decimal_point'], $locale['thousands_sep']);
            echo "</h2>";
    ?>
        
</body>
</html>
 
beaner_06
Forum Newbie
Posts: 13
Joined: Tue May 19, 2009 6:11 pm

Re: Hide PHP script until User Submits Data

Post by beaner_06 »

Nevermind. I figured it out.
Post Reply