TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Software World > Programming

Notices

Reply
 
Thread Tools Display Modes
Old 05-06-2008, 10:55 PM   #1
Newbie
 
Join Date: Jun 2008
Age: 25
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 ekumar is an unknown quantity at this point
Thumbs down Display problem

I tuped this <html> and PHP code In notepad and save in the same name but no display come in the internet page. (Where does the problem occured ?)





<html>
<head>
<title> Switch form</titile>
</head>
<body>
<form method="POST" action="switch reasult.php">
Enter first Num:<input type="text"name="num1"><br>
Enter second num:<input type="text"name="num2"><br>
<u>select Operator<br></u>
<input type="radio"name="operator"value="add">Add
<input type="radio"name="operator"value="sub">Sub
<input type="radio"name="operator"value="mul">Mul
<input type="radio"name="operator"value="div">Div<br>
<input type="submit" value="calculate">
<input type="reset" value="clear">
</form>
</body>
</html>
<?php
$a=$_POST['num1'];
$b=$_POST['num2'];
$oper=$_POST['opeartor'];
echo"your first no:$a<br>";
echo"your second no:$b<br>";
switch($oper)
{
case addd:
$add=$a+$b;
echo"sum of $a and $b is :$add<br>";
break;
case sub:
$sub=$a-$b;
echo"Difference of $a and $b is:$sub<br>";
break;
case mul:
$mul=$a*$b;
echo"product of $a and $b is :$mul<br>";
break;
case div:
$div=$a/$b;
echo"division of $a and $b is:$div<br>";
break;
default:
{
echo"You must select an operator<br>";
}
?>
ekumar is offline   Reply With Quote
Old 06-06-2008, 12:41 AM   #2
ƒ(ψ)=ΘΊΧφ
 
bakuryu's Avatar
 
Join Date: May 2006
Location: India
Age: 22
Posts: 5,027
Thanks: 12
Thanked 392 Times in 362 Posts
Rep Power: 69 bakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant futurebakuryu has a brilliant future
Send a message via Yahoo to bakuryu
Re: Display problem

did you install PHP ? Are you using Apache ?? Also I am not sure weather case works with Strings also, and in any case have it as case "add" or case 'add'
__________________
Please don't click here
bakuryu is offline   Reply With Quote
Old 08-06-2008, 10:28 PM   #3
Junior Member (25+)
 
anniepoo's Avatar
 
Join Date: Oct 2006
Posts: 48
Thanks: 20
Thanked 5 Times in 4 Posts
Rep Power: 0 anniepoo is an unknown quantity at this point
Re: Display problem

You've failed to close the <title> tag properly.
<title> Switch form</titile>

Get rid of the extra i in </titile>
the form submits to action="switch reasult.php"
which looks suspiciously like a misspelling

It's not clear why you want to put the php code below the HTML.
I think you want this in two separate files on your server. The second file
should be named result.php and should have the stuff starting with the line
<?
everything above it should be in a file called form.html
and you should change the misspelling above
action="switch reasult.php"
to
action="result.php"

Your real problem is best illustrated by a koan
JJ Thompson found a grad student trying to repair a LISP machine by power cycling it.
He said, "You cannot repair a machine by simply turning it on and off. You must understand how it works before you can repair it"
Thompson then peered at the machine, power cycled it, and the machine came up.

The lesson here, is that you need to understand what PHP is, what a form is, and how HTTP protocol lets the form submit a request to the PHP page. Only then will your errors make sense.
anniepoo is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Google
 


All times are GMT +5.5. The time now is 05:42 AM.


vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2008, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional