Jump to content

[SOLVED] $_REQUEST not doing as I expect


stockton

Recommended Posts

I have written the following and am confused as to why when the script reloads I cannot retrieve the html fields via $_REQUEST.

Will someone please tell me what I have done silly.

<?php
require_once('includes/logo.inc');
require_once('includes/configuration.php');     // database connect script & the rest.
/*
*  We 1st check if user has logged on and has the necessary authority.
*/
//    echo ("Earn Rate Create at erate.php<br/>");
    $Ding = $_REQUEST["submit1"];
    $EarnRateTitle = $_REQUEST["EarnRateTitle"];
    $SlotsRate     = $_REQUEST["SlotsRate"];
    echo "ding = ".$Ding." <br/>";
    echo ("EarnRateTitle = ".$EarnRateTitle." SlotsRate = ".$SlotsRate."<br/>");
    if ($_SESSION['UID'] < 1)       // Not logged in
        {
        $Message = sprintf("%s %d <br> Logon to be able to access this task!", __FILE__, __LINE__);
        trigger_error($Message, E_USER_ERROR);
        exit;
        }
    if ($Ding == "")    // 1st time display the screen
        {
        $Ding = 1;
        }
    else
    if ($Ding == 1)     // Hopefully something got entered so do calculation
        {
        $Ding = 2;
        if (($EarnRateTitle == "") || ($SlotsRate == ""))
            {
            $Message = sprintf("%s %d <br> Please enter both fields!", __FILE__, __LINE__);
            trigger_error($Message, E_USER_ERROR);
            exit;
            }
        $RouletteRate   = $SlotsRate*$TheoreticalHold[slots]/$TheoreticalHold[Roulette];
        $BlackJackRate  = $SlotsRate*$TheoreticalHold[slots]/$TheoreticalHold[blackJack];
        $PuntoBancoRate = $SlotsRate*$TheoreticalHold[slots]/$TheoreticalHold[PuntoBanco];
        $PokerRate      = $SlotsRate*$TheoreticalHold[slots]/$TheoreticalHold[Poker];
        echo ("Roulette = ".$RouletteRate." BlackJack = ".$BlackJackRate." PuntoBlance = ".$PuntoBlancoRate." Poker = ".$PokerRate);
        }
    else
    if ($Ding == 2)     // Previous calculations accepted
        {
        }

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<title>Earn Rate Create</title>
<meta name="author" content="Alf Stockton">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT">
</head>
<body onload="BodyOnLoad()">
<h2>Create Earn Rate</h2>
<form method="get" name="EarnRateCreate" id="EarnRateCreate" > <!-- action="<?php echo $PHP_SELF; ?> " > -->
<TABLE BORDER CELLPADDING=3 align=center>
<TR BGCOLOR="deeppink">
   <TH>Description</TD>
   <TH>Slots</TD>
   <TH>Roulette</TD>
   <TH>BlackJack</TD>
   <TH>PuntoBanco</TD>
   <TH>Poker</TD>
</TR>

<TR BGCOLOR="#FFFFCC">
   <TD><input type="text" name="EarnRateTitle" id="EarnRateTitle" size=20></TD>
   <TD><input type="text" name="SlotsRate" id="SlotsRate" size=10></TD>
   <TD><input type=text disabled name="RouletteRate" id="RouletteRate" size=10></TD>
   <TD><input type=text disabled name="BlackJackRate" id="BlackJackRate" size=10></TD>
   <TD><input type=text disabled name="PuntoBancoRate" id="PuntoBancoRate" size=10></TD>
   <TD><input type=text disabled name="PokerRate" id="PokerRate" size=10></TD>
   </TR>
</table>
<center>
<input type=hidden name="submit1" id="submit1" value="<?php echo $Ding; ?>" >
<P>
<a href="erate.php"><img src=images/Submit.png name="submit" value="submit" border=0>
<a href="erate.php"><img src=images/AddNew.png name="addnew" value="addnew" border=0>
<a href="Administration.php"> <img src="images/Back.png" border=0> </a>
</p>
</center>
</FORM>
</body>
</html>
<script type="text/javascript">
function BodyOnLoad()
    {
    document.getElementById('EarnRateTitle').focus();
    }
</script>

Link to comment
Share on other sites

have a read of this article on $_REQUEST

 

Instead of using $_REQUEST, you could do something like...

 

<?php

  foreach ($_POST as $key => $value) {
      $cgi[$key] = $value;
  }
  foreach ($_GET as $key => $value) {
      $cgi[$key] = $value;
  }

 

then all $_POST's and $_GET's will be accessible by $cgi

Link to comment
Share on other sites

Your form does not have any submit input fields, so the form won't be submitted. You have links using images, which won't submit a form unless you add some javascript. What you have now are just some links. Why aren't you just using images in the submit input fields.

Link to comment
Share on other sites

Maybe the echo sentences at the beginning of the script are creating an incorrect HTML code.  You could try to include the whole script inside the html body (just after de <body> tag).

 

Your codeshould start like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
        "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<title>Earn Rate Create</title>
<meta name="author" content="Alf Stockton">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="Mon, 22 Jul 2000 11:12:01 GMT">
</head>
<body onload="BodyOnLoad()">
<?php /*YOUR SCRIPT*/ ?>

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.