943,783 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 5586
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
May 29th, 2009
0

Re: PostBack method on Page Refresh

I cant explain to you everything about sessions but I can give you an example, that will hopefully solve your problem.

PHP Syntax (Toggle Plain Text)
  1. // PAGE 1
  2. session_start();
  3. $_SESSION['abc'] = "2";
  4.  
  5. // PAGE 2
  6. session_start();
  7. echo $_SESSION['abc];
  8.  

Understand the logic behind it now?

Let me know how you go.
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 29th, 2009
0

Re: PostBack method on Page Refresh

Click to Expand / Collapse  Quote originally posted by OmniX ...
I cant explain to you everything about sessions but I can give you an example, that will hopefully solve your problem.

PHP Syntax (Toggle Plain Text)
  1. // PAGE 1
  2. session_start();
  3. $_SESSION['abc'] = "2";
  4.  
  5. // PAGE 2
  6. session_start();
  7. echo $_SESSION['abc];
  8.  

Understand the logic behind it now?

Let me know how you go.
yes sir i understand the code but sir value '2' is dynamic not static..!!! value can be 2,3,4 etc whatever user can input in it..!!!!

in my example you clearly see, i take '2' as userinput not static input..!!!

//now page1
session_start();
$_SESSION['abc'] = ??? // how will you collect value of userinput
without sending it anywhere..!!


<input type='text' value="echo $_SESSION['abc'] " name="abc">

<!-- you dont know what user going to input.. -->

I hope now you get what exactly i want..!!!
Last edited by nish123; May 29th, 2009 at 3:03 am.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
nish123 is offline Offline
83 posts
since Apr 2009
May 29th, 2009
0

Re: PostBack method on Page Refresh

Quote ...
is it possible to have Postback method on page Refresh.??
(Hold the values of a form on page refresh..!!)
You want to preserve the data or state of form input tag even after the page is posted back.

State management : home-made measures needed to preserve the state. Traditionally, statlessness hav been overcome with use of cookies, session, hidden fields, sticky form, and query string.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
May 29th, 2009
0

Re: PostBack method on Page Refresh

Here is an example code for everything to solves your questions:

php Syntax (Toggle Plain Text)
  1. // Page 1
  2. session_start(); // Starts the session
  3. <input type="textbox" name="textbox_name" /> // User enters 123
  4. $_SESSION['textbox_session'] = $_POST['textbox_name'];
  5.  
  6. // Page 2
  7. session_start(); // Starts the session
  8. echo $_SESSION['textbox_session'];

You understand the logic? If not do some research?
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 29th, 2009
0

Re: PostBack method on Page Refresh

adatapost>Example code is not a solution after all. If a person is not able to program himself/herself then he/she must introspect.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
May 29th, 2009
0

Re: PostBack method on Page Refresh

The logic behind the code answers all his questions.
If he has further questions he just needs to ask.
adatapost > If you have nothing positive to add best not post than to be thought an idiot.
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
May 30th, 2009
0

Re: PostBack method on Page Refresh

Click to Expand / Collapse  Quote originally posted by OmniX ...
Here is an example code for everything to solves your questions:
php Syntax (Toggle Plain Text)
  1. // Page 1
  2. session_start(); // Starts the session
  3. <input type="textbox" name="textbox_name" /> // User enters 123
  4. $_SESSION['textbox_session'] = $_POST['textbox_name'];
  5.  
  6. // Page 2
  7. session_start(); // Starts the session
  8. echo $_SESSION['textbox_session'];
You understand the logic? If not do some research?
Sorry sir but i dont understand that why you use $_POST when you not sending any data anywhere...
I hope you know that :
The built-in $_POST function is used to collect values from a form sent with method="post".

But we are here not sending data anywhere so it is useless to use $_POST..!!! thats what i m saying from very starting..!! I have to Hold data on page refresh(without using submit or without using any event)..!!!!
Sir this time you need to research little bit..!!!

Thanks for your Kind Patience..
Last edited by nish123; May 30th, 2009 at 2:40 am.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
nish123 is offline Offline
83 posts
since Apr 2009
May 31st, 2009
0

Re: PostBack method on Page Refresh

How can you not be sending data?
The layout of your example, you would presumme it would be sending data.
If you not going to use 'post' use another 'session'.

List your code im getting tired of trying to guess what it is
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007
Jun 1st, 2009
0

Re: PostBack method on Page Refresh

Click to Expand / Collapse  Quote originally posted by OmniX ...
How can you not be sending data?
The layout of your example, you would presumme it would be sending data.
If you not going to use 'post' use another 'session'.

List your code im getting tired of trying to guess what it is
Respected Sir i dont thnk my very first post was difficult to understand..!!! Now i try my best to made it more clear....!!!

PHP Syntax (Toggle Plain Text)
  1. <form action="add.php" method="post">
  2. <table>
  3. <tr>
  4. <td>Items</td>
  5. <td>Price</td>
  6. </tr>
  7. <tr>
  8. <? while($row=mysql_fetch_array($result)) { ?>
  9. {
  10. <td><?= $row['Item']; ?> </td> //this will fetch Item from DB..
  11. <td><input type="text" name="price"></td>
  12. // in this text box user input the price..!!
  13. <?}?>
  14. <button type="button" onclick="return myPopup2();"><span>Add New Item</span></button></td>
  15.  
  16. // This Add New Item Button will open a popup window through which I can add new Item... and on close of pop-up window the parent page will REFRESH... So that the NEW ITEM can be Displayed in the List..!!!
  17.  
  18. Note : Add Button is not a Submit button.. it jst call a Javascript Function to open a Window..!!

Now i want to Hold the Value of Price TextBox which user input in it at time page refresh..!!

Suppose User got the page with 5 items...!!!

ITEMS | PRICE
ITEMS1 | 50 // Items are coming from db and User input the Price
ITEMS2 | 30
ITEMS3 | 20
ITEMS4 | 40
ITEMS5 | 60
ADD New ITEM (Button) // After Filling the Prices of First 5 Items,User Feels that He forgot to add ITEM 6 then he will Click on Add Item Button,a Popup Window Will Open through Which User Add Item 6 and on Close of that window... the Parent page will Refresh and Item 6 will displayed in the list..!!! But the values which User filled in Price textbox will be vanished...!!!

and I want to hold that Price Value on page refresh...!!!!

Now i hope clear Idea whta i want...??
I hope You reply with a Good Solution..!!

Thnk You Sir.!!!
Last edited by nish123; Jun 1st, 2009 at 2:01 am.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
nish123 is offline Offline
83 posts
since Apr 2009
Jun 1st, 2009
0

Re: PostBack method on Page Refresh

Ok thats better now I understand your situation abit better.

But still you get the same answer, you have tried $_SESSION and $_POST ? Im sure either one would work if $_POST does not work cause technically there has been no information sent then sessions should work. popup2() is a function that opens a new php page I gather? So you should be able to declare either $_SESSION or $_POST within the value parameters of those text boxes.

In short have you tried $_POST or $_SESSION?
or you do not know how to implement either?
Reputation Points: 31
Solved Threads: 10
Practically a Master Poster
OmniX is offline Offline
652 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how do i do three WHERE clauses with php (mysql)
Next Thread in PHP Forum Timeline: PHP Dynamic links?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC