473,756 Members | 3,499 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can I make a var survive page reload?

Mo
I am trying to calculate open-account credibility for new customers.

I have set up a form in which to enter the feedback from their trade
references, but the vars get reset each time the page loads.
The page is terms.php, and I intentionally have it processing itself
because I need the user to be able to repeatedly enter feedback, or
stop at any time, and get results of the compiled avg's regardless.

For example (very simplified): ------------
<form action="terms.p hp" method="post">
<input type="hidden" name="formCount " value="1">
Terms: Net <input type="text" name="formTerms " size="2" value=""/>
Days
Avg Days to Pay: <input type="text" name="formDaysP aid" size="2"
value=""/>
</form>

if(isset($_POST["formCount"]))
{
$count += $_POST["formCount"];
$terms += $_POST["formTerms"];
$avgDays += $_POST["formDaysPa id"];
}

$score = $terms/$avgDays*100;
$score /= $count;

print "Score: {$score}";
-------------------------------------------

When submitted, I want the score, as well as the form available for
more values. This is why it must post to itself.
When submitted AGAIN, I want the current values $count, $terms, and
$avg to survive the reload, and get the new $_POST values added into
their current values.

IE:
Terms: [ 30 ]
Avg Days to Pay: [ 32 ]
*submit*

Terms: [ 45 ]
Avg Days to Pay: [ 55 ]
*submit*

Terms: [ 15 ]
Avg Days to Pay: [ 30 ]
*submit*

Desired values would now be $count=3, $terms=90, and $avgDays=117.
$score would calculate out at 25.64.

As I have it right now, each time I hit the submit button, $count,
$terms, and $avg get NEW values.

Any Tips?
~ Mo
Oct 2 '08 #1
2 3169
On Oct 3, 12:43*am, Mo <Mehile.Orl...@ gmail.comwrote:
I am trying to calculate open-account credibility for new customers.

I have set up a form in which to enter the feedback from their trade
references, but the vars get reset each time the page loads.
The page is terms.php, and I intentionally have it processing itself
because I need the user to be able to repeatedly enter feedback, or
stop at any time, and get results of the compiled avg's regardless.

For example (very simplified): ------------
<form action="terms.p hp" method="post">
<input type="hidden" name="formCount " value="1">
Terms: Net <input type="text" name="formTerms " size="2" value=""/>
Days
Avg Days to Pay: <input type="text" name="formDaysP aid" size="2"
value=""/>
</form>

if(isset($_POST["formCount"]))
{
$count *+= $_POST["formCount"];
$terms += $_POST["formTerms"];
$avgDays += $_POST["formDaysPa id"];

}

$score = $terms/$avgDays*100;
$score /= $count;

print "Score: {$score}";
-------------------------------------------

When submitted, I want the score, as well as the form available for
more values. This is why it must post to itself.
When submitted AGAIN, I want the current values $count, $terms, and
$avg to survive the reload, and get the new $_POST values added into
their current values.

IE:
Terms: [ 30 ]
Avg Days to Pay: [ 32 ]
*submit*

Terms: [ 45 ]
Avg Days to Pay: [ 55 ]
*submit*

Terms: [ 15 ]
Avg Days to Pay: [ 30 ]
*submit*

Desired values would now be $count=3, $terms=90, and $avgDays=117.
$score would calculate out at 25.64.

As I have it right now, each time I hit the submit button, $count,
$terms, and $avg get NEW values.

Any Tips?
~ Mo
The 4 most common methods in PHP to do this are sessions, cookies,
hidden form fields and query string parameters. Cookies and sessions
are documented in the PHP manual. The hidden form fields involves
creating a hidden form field (duh :) ) and populating it with a
variable you want to preserve. Query strings are similar but you can
also use them in URLs.
Oct 3 '08 #2
Mo
On Oct 3, 3:12*am, Gordon <gordon.mc...@n tlworld.comwrot e:
On Oct 3, 12:43*am, Mo <Mehile.Orl...@ gmail.comwrote:
I am trying to calculate open-account credibility for new customers.
I have set up a form in which to enter the feedback from their trade
references, but the vars get reset each time the page loads.
The page is terms.php, and I intentionally have it processing itself
because I need the user to be able to repeatedly enter feedback, or
stop at any time, and get results of the compiled avg's regardless.
For example (very simplified): ------------
<form action="terms.p hp" method="post">
<input type="hidden" name="formCount " value="1">
Terms: Net <input type="text" name="formTerms " size="2" value=""/>
Days
Avg Days to Pay: <input type="text" name="formDaysP aid" size="2"
value=""/>
</form>
if(isset($_POST["formCount"]))
{
$count *+= $_POST["formCount"];
$terms += $_POST["formTerms"];
$avgDays += $_POST["formDaysPa id"];
}
$score = $terms/$avgDays*100;
$score /= $count;
print "Score: {$score}";
-------------------------------------------
When submitted, I want the score, as well as the form available for
more values. This is why it must post to itself.
When submitted AGAIN, I want the current values $count, $terms, and
$avg to survive the reload, and get the new $_POST values added into
their current values.
IE:
Terms: [ 30 ]
Avg Days to Pay: [ 32 ]
*submit*
Terms: [ 45 ]
Avg Days to Pay: [ 55 ]
*submit*
Terms: [ 15 ]
Avg Days to Pay: [ 30 ]
*submit*
Desired values would now be $count=3, $terms=90, and $avgDays=117..
$score would calculate out at 25.64.
As I have it right now, each time I hit the submit button, $count,
$terms, and $avg get NEW values.
Any Tips?
~ Mo

The 4 most common methods in PHP to do this are sessions, cookies,
hidden form fields and query string parameters. *Cookies and sessions
are documented in the PHP manual. *The hidden form fields involves
creating a hidden form field (duh :) ) and populating it with a
variable you want to preserve. *Query strings are similar but you can
also use them in URLs.
Thank you both for the direction.
I now know where to dig.

~ Mo
Oct 3 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4821
by: zdhiu | last post by:
Hi javascript gurus, I have a simple html file (simple.html) with javascript. In html page there is sentence from variable defined in .js file (myFirst.js). Once I reload another .js file (mySecond.js), the value defined in the second one is NOT reloaded into html page. Please help out what's wrong in my code. BTW, I use IE6.0
37
12748
by: ajay | last post by:
How to make a web page getting refreshed after a given time interval automatically. HTML Code plz. Tx Ajay
18
10144
by: Alan Z. Scharf | last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want the page to refresh at the end of each callback to display A. Results of a SQLServer query showing cumulative running time, and B. A progress bar. 2. I have this working with a refresh timer: <META http-equiv="refresh" content="5">
8
2072
by: Salvatore Sanfilippo | last post by:
Hello all, I've a very simple problem that appears to don't have a simple solution. I've a (dynamically generated) page with a number of external links. What I need is that if the user clicks on an external link, before to reach the link, the current page gets reloaded. My first try was the obvious:
8
6827
by: T. Wintershoven | last post by:
Hi all, Is there a simple way in php to reload a page coded within an if statement.(see code below) It's very important that the session stays intact. The filename is RCStudent.php **************** A peace of code*************************** <?php session_start();
2
1903
by: Max | last post by:
Is it possible to reload a web page on user browser when an event occurs at server side? For example when user A places an order, user B should be notified of that and should see that order on his page. I 'd like to avoid to reload B page every nnn seconds. Or at least, I'd like to check if something interesting has changed on server and only in that case to reload the page. Any suggestion? Thanks Max
16
16683
by: sreemati | last post by:
Hi everyone, This is the scenario: I have two button - Submit and Reset Submit is used for validation and after validation is passed it passes it to another form to enter into database. Bascially the reset works fine if I use it before using the submit button in the form. For instance,if on submit there is some error as the values have not passed a validation. There is a error pop up message shown and the values are retained in...
5
3752
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi, I used the following code to refresh the parent page, and it works very well (Thanks to Peter Bromberg "). Response.Write("<script language='javascript' type='text/javascript'{ window.opener.location = 'Default.aspx?Reload=100'; }</script>"); Response.Write("<script language='javascript' type='text/javascript'{ self.close(); }</script>");
2
12906
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh all of them - from the server (this could be on page refresh also) as the purpose is to reset the iframe to the original content in case the user clicked on a link in that iframe and changed it, but also in case there were updates to the original page...
4
398
by: Mo | last post by:
I am trying to calculate credibility for new customers so they can attain open-account. I have set up a form (on test.php, and processed by the same page) into which feedback from their trade references is entered, but the vars get reset each time the page loads. I intentionally have it processing itself because I need the user to be able to repeatedly enter feedback, or stop at any time, and get results of the compiled avg's regardless.
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9273
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9841
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9711
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7244
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5303
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.