473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

problem in value printing in a textbox which is in another page

I want to add,subtract,multiply and divide two nos in a form for which i have 2 textboxes and for displaying o/p there is another textbox.there is 4 submit buttons which represent + - * /. after that i want to go next page that is in form action and after that the first page text box will display the result for a particular operation.

I have already written the code of this 2 pages.

1st page code:

Expand|Select|Wrap|Line Numbers
  1. <form action="http://bytes.com/next.php" method="post" enctype="multipart/formdata">
  2.  
  3. 1st No:<input type="text" name="n" id="t1"><br>
  4.  
  5. 2nd No:<input type="text"name="n1" id="t2"><br> <input type="submit" name="butt" id="b1" value="+"> <input type="submit" name="butt" id="b2" value="-"> <input type="submit" name="butt" id="b3" value="*"> <input type="submit" name="butt" id="b4" value="/"><br>
  6.  
  7. Result is<input type="text" name="r" id="t3" value="<?php if(isset($_SESSION['b'])){echo $_SESSION['b'];}?>"> </form>
2nd page code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $n=$_REQUEST['n'];
  6.  
  7. $_SESSION['n2']=$n;
  8.  
  9. $n1=$_REQUEST['n1'];
  10.  
  11. $_SESSION['n3']=$n1;
  12.  
  13. $butt=$_REQUEST['butt'];
  14. if($butt=='+')
  15.  
  16. {
  17.  
  18. $res=$n+$n1;
  19.  
  20. $_SESSION['b']=$res;
  21. }
  22.  
  23. else if($butt=='-')
  24.  
  25. {
  26.  
  27. $res=$n-$n1;
  28.  
  29. $_SESSION['b']=$res;
  30. }
  31.  
  32. else if($butt=='*')
  33.  
  34. {
  35.  
  36. $res=$n*$n1;
  37.  
  38. $_SESSION['b']=$res;
  39. }
  40.  
  41. else if($butt=='/')
  42.  
  43. {
  44.  
  45. $res=$n/$n1;
  46.  
  47. $_SESSION['b']=$res;
  48.  
  49. }
  50.  
  51. else
  52. {
  53.  
  54. echo "enter number";
  55.  
  56. }
  57. echo "<script>window.location.href='form1.php'</script>";
  58.  
  59.  
  60. ?>
what is the problem in this code?kindly help
Oct 13 '14 #1
0 1141

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Sergei | last post by:
Hi, I am displaying modal dialog and passing values from the main form to the modal dialog and back. It works fine but if I used the following syntax on Page_Load(just for testing) in VB to...
2
by: ABC | last post by:
How to pre-set combo textbox's selectedindex value from querystring passed from another page? I pass the querystring to set combo text box (change selectedindex on Page_Init). Source code as: ...
17
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the...
6
by: Chris | last post by:
I created a very simple web page in asp.net. there are only a textbox and a button on the page. when the page loads into web browser there is current date in the textbox. but the date can be...
3
abdoelmasry
by: abdoelmasry | last post by:
Hi Friends i need help in sessions im passing variables between pages using sessions this is the main page thats mean the home page the main page have table to show messages for users , it have...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
3
NawazAhmed
by: NawazAhmed | last post by:
Hi, I am working with Visual Studio 2003, framework 1.1 I am trying to focus a textbox when page loads. I tried Page.RegisterStartupScript("focus",...
1
by: abirami elango | last post by:
Hi, i have created a web application in vb.net. i have assigned a value to the textbox during page UNLOAD event as below.. ......... Protected Sub Page_Unload(ByVal sender As Object, ByVal e As...
1
oranoos3000
by: oranoos3000 | last post by:
hi I want to direct user in middle page in terms of result of conditions to different pages and I have to use html tage or echo statement befor this conditions what statement can I use other...
7
by: upcomingaman | last post by:
I am developing a add to cart page I'm using using DataList to display items and a small TextBox with default value "1" to show quantity. if user change this value to some other integer then the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.