bskauge Posted February 27, 2007 Share Posted February 27, 2007 This was working some time ago about, but suddenly, without any changes, it didn't work anymore. This should be pretty basic, but I have no idea why this isn't working. I have a form that asks for three numbers, and based on these numbers there will be a mathematical operation, and the answer will be given on the same page when you hit "beregn!" ("calculate" in english). The problem is that the answer doesn't show up, can anyone help me find out why? My host is running php version 5.2.0, this may have been upgraded, can't remember the last version. The page is located here: http://www.onlymalts.com/v2/tools/kalkistest.php And this is some of the code: <?php $alc2 = 1.00; ?> <div id="Layer1" style="position:absolute; left:210px; top:306px; width:472px; height:160px; z-index:7;"> <span class="tekst"> <form id="form2" name="form2" method="post" action=""> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25%">Antall cl: </td> <td width="75%"><input name="cl" type="text" size="4" /></td> </tr> <tr> <td>Alkoholnivå i %:</td> <td><input name="alc" type="text" size="4" /></td> </tr> <tr> <td>Ønsket styrke i %:</td> <td><input name="styrke" type="text" size="4" /></td> </tr> </table> <br /> <input type="image" src="/v2/bilder/beregn.jpg" /> </form> <?php if ($cl == NULL) echo ' '; elseif ($styrke == 0) echo 'Vann finner du i springen!'; elseif ($alc==0) echo 'Vi skulle gjerne hjulpet deg med å gjøre vann om til whisky, vi jobber med saken. I mellomtiden anbefaler vi å ta turen innom polet.'; elseif ($cl==0) echo 'Har du ikke whisky? Ikke en eneste dråpe?!'; elseif ($styrke>$alc) echo 'Du må tilsette sterkere whisky for å få mer alkohol. Dette er en vannkalkulator!'; elseif ($alc>96) echo 'Det er vel lite sannsynlig at du har fått tak i noe som er sterkere enn 96%.'; elseif ($styrke>0) { $alc2 = &$styrke; $resultat = $cl*($alc/$alc2)-$cl; echo 'Du må tilsette ' .number_format($resultat,1).' cl vann i '.$cl.' cl med '.$alc.'% whisky for å få '.$alc2.'%.'; } ?> </span> <br /><br /><? include("../disclaimer.php") ?> </div> Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/ Share on other sites More sharing options...
r-it Posted February 27, 2007 Share Posted February 27, 2007 what is your form's action? Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195123 Share on other sites More sharing options...
Yesideez Posted February 27, 2007 Share Posted February 27, 2007 I can't see anywhere that you're using $_POST to get the values once the user clicks the submit button. Is this all of the script? @r-it - the action is empty meaning itself Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195126 Share on other sites More sharing options...
Yesideez Posted February 27, 2007 Share Posted February 27, 2007 I just viewed the page - I can see it's not all of the script. You need this somewhere... $cl=$_POST['cl']; $alc=$_POST['alc']; Preferable in the php section at the top. Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195127 Share on other sites More sharing options...
ashly Posted February 27, 2007 Share Posted February 27, 2007 Use the code below in the top of the page And do your calculation after these lines and do what do you want to do... $cl = $_POST['cl']; $alc = $_POST['alc']; $styrke = $_POST['styrke']; Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195128 Share on other sites More sharing options...
Yesideez Posted February 27, 2007 Share Posted February 27, 2007 Use the code below in the top of the page And do your calculation after these lines and do what do you want to do... $cl = $_POST['cl']; $alc = $_POST['alc']; $styrke = $_POST['styrke']; Oops I missed one - well done ashly Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195129 Share on other sites More sharing options...
bskauge Posted February 27, 2007 Author Share Posted February 27, 2007 Thank you, ashly, that did the trick. I don't have the slightest clue why this worked before, it just did. Solved now. Link to comment https://forums.phpfreaks.com/topic/40329-solved-basic-form-doesnt-work/#findComment-195130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.