Jump to content
  • 0

Не работает калькулятор


maitan
 Share

Question

Дорогие друзья.

У меня не работает калькулятор который я для примера скачал в интернете. Существуют 2 файла, один - index.php "лицо" калькулятора, а второй result.php собственно обрабатывает запрос.

Коды:

index.php


<HTML>
<HEAD>
<TITLE>Simple Calculator by Peter Rekdal Sunde</TITLE>
</HEAD>
<BODY bgcolor="#57738E">


<p> </p>


<p> </p>



<p> </p>



<p> </p>



<p> </p>



<p> </p>



<p> </p>



<p> </p>
<div align="center">
<center>
<table border="0" width="966" height="203">
<tr>
<td width="966" height="1" bgcolor="#FFFFFF" align="center">
<p align="center"><font face="Verdana" size="1"><b>
<marquee>Download this code at <a href="http://www.planet-source-code.com">http://www.planet-source-code.com</a></marquee>
</b></font></td>
</tr>
<tr>
<td width="966" height="241" align="center">



<FORM METHOD="post" ACTION="result.php">

<P><font face="Verdana" size="2"><b>Calculation number 1: <INPUT TYPE="text" NAME="val1" SIZE=10></b></font></p>

<P><font face="Verdana" size="2"><b>Calculation number 2: <INPUT TYPE="text" NAME="val2" SIZE=10></b></font></p>

<p><font face="Verdana" size="2"><b>Calculation type:</b></font></p>

<p><font face="Verdana" size="2"><b><input TYPE="radio" NAME="calc" VALUE="addisjon">
add <input TYPE="radio" NAME="calc" VALUE="minus"> subtract <input TYPE="radio" NAME="calc" VALUE="ganger">
multiply <input TYPE="radio" NAME="calc" VALUE="dele"> divide</b></font></p>

<P><INPUT TYPE="submit" NAME="submit" VALUE="Do Calculation"></p>

</FORM>


</td>
</tr>
<tr>
<td width="966" height="1" bgcolor="#FFFFFF">
<p align="center"><font face="Verdana" size="1"><b>This script was
created by Peter Rekdal Sunde</b></font></td>
</tr>
</table>
</center>
</div>

</BODY>
</HTML>

result.php


<HTML>
<HEAD>
<TITLE>Simple Calculator by Peter Rekdal Sunde</TITLE>
</HEAD>
<BODY bgcolor="#57738E">


<p> </p>


<p> </p>



<p> </p>



<p> </p>



<p> </p>
<?

#######################################
# Release date: 10.09.01
# Coding time: 5 minutes with graphical interface!
# Coded in: php
# Description: Calculator/Graphical user interface!
#
#
# Coder: Exion ( Peter Rekdal Sunde )
# Version: Calc v1.0



######### Start of code ##########

if ($calc == "addisjon") {
$svar = $val1 + $val2;
} else if ($calc == "minus") {
$result = $val1 - $val2;
} else if ($calc == "ganger") {
$svar = $val1 * $val2;
} else if ($calc == "dele") {
$svar = $val1 / $val2;
}


?>


<p> </p>



<p> </p>



<p> </p>
<div align="center">
<center>
<table border="0" width="966" height="203">
<tr>
<td width="966" height="1" bgcolor="#FFFFFF" align="center">
<p align="center"><font face="Verdana" size="1"><b>
<marquee>Download this code at http://www.planet-source-code.com</marquee>
</b></font></td>
</tr>
<tr>
<td width="966" height="241" align="center">



<FORM METHOD="post" ACTION="calculate.php">
<?
if (!$val1) die("<b><font face=\"verdana\" size=\"2\">Sorry, but you forgot to fill-in Field 1!");
if (!$val2) die("<font face=\"verdana\" size=\"2\"<b>Sorry, but you forgot to fill-in Field 2!");
if (!$calc) die("<b><font face=\"verdana\" size=\"2\">Sorry, but you forgot to choose Calculation type!!");
?>
<P><font face="Verdana" size="2"><b>The result of your calculation is:</b></font></p>

<P><font face="Verdana" size="2"><b> <? echo $svar; ?> </b></font> </p>



<P>  </p>


</FORM>



</b></b>



</font></font></font>



</td>
</tr>
<tr>
<td width="966" height="1" bgcolor="#FFFFFF">

<p align="center"><font face="Verdana" size="1"><b>This script was
created by Peter Rekdal Sunde</b></font></td>
</tr>
</table>
</center>
</div>

</BODY>
</HTML>

Дело в том, что такое ощущение что до result.php просто не доходят значения, вводимые в index.php. Помогите разобраться, пожалуйста.

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  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.

 Share

×
×
  • 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. See more about our Guidelines and Privacy Policy