![]() |
|
|
#1 |
|
Newbie
Join Date: Jun 2008
Age: 25
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
![]() |
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>"; } ?> |
|
|
|
|
|
#2 |
|
ƒ(ψ)=ΘΊΧφ
![]() |
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 |
|
|
|
|
|
#3 |
|
Junior Member (25+)
Join Date: Oct 2006
Posts: 48
Thanks: 20
Thanked 5 Times in 4 Posts
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|