stockton Posted October 22, 2008 Share Posted October 22, 2008 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 https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/ Share on other sites More sharing options...
MasterACE14 Posted October 22, 2008 Share Posted October 22, 2008 change your $_REQUEST to $_GET, see if it works then. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671529 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 Unfortunately it does not. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671545 Share on other sites More sharing options...
MasterACE14 Posted October 22, 2008 Share Posted October 22, 2008 $_POST maybe? As far as I can tell, your using the GET method though. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671547 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 Yes, the form method="get" but from what I understand from the manual $_REQUEST should work for either method="post" or method="get" Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671549 Share on other sites More sharing options...
MasterACE14 Posted October 22, 2008 Share Posted October 22, 2008 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 https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671552 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 Tried your suggestion but still without success. I am not getting anything back. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671557 Share on other sites More sharing options...
MasterACE14 Posted October 22, 2008 Share Posted October 22, 2008 that is strange, maybe something is disabled in your PHP configuration? I honestly have no idea why none of the above is working. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671565 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 I doubt that it is a configuration problem as $_REQUEST works fine in other scripts I have on the same machine. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671567 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 I am now convinced that it is a HTML issue not a PHP problem at all. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671574 Share on other sites More sharing options...
haku Posted October 22, 2008 Share Posted October 22, 2008 Have you set $PHP_SELF? If not, your form isn't going to work. In which case, it's both a php problem and an HTML problem. PHP because you aren't setting the php right, and HTML because it doesn't have an action for the form. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671577 Share on other sites More sharing options...
PFMaBiSmAd Posted October 22, 2008 Share Posted October 22, 2008 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 https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671578 Share on other sites More sharing options...
feidakila Posted October 22, 2008 Share Posted October 22, 2008 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 https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671581 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 I have solved the problem and what PFMaBiSmAd said above covered most of the issues. Thank all. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671584 Share on other sites More sharing options...
stockton Posted October 22, 2008 Author Share Posted October 22, 2008 By the way feidakila, I do not believe that it makes much difference if the HTML is on top or the PHP. If anyone else has any others ideas I would appreciate hearing them. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671628 Share on other sites More sharing options...
MasterACE14 Posted October 22, 2008 Share Posted October 22, 2008 order of HTML and PHP doesn't matter. Except for headers, and sessions, which have to come before any HTML output. Link to comment https://forums.phpfreaks.com/topic/129518-solved-_request-not-doing-as-i-expect/#findComment-671629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.