By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,721 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,721 IT Pros & Developers. It's quick & easy.

(n00b) One script, multiple transactions

P: n/a
I'm an experienced C/C++ programmer learning PHP.

I'm currently trying to write a simple unit converter script. I thought
I saw a tutorial somewhere that used isset() to determine whether the
script is running for the first time, initialize if so, perform the
usual function otherwise. But my own attempt at this doesn't seem to
work. Every time I hit Submit, my start-up branch runs, variables are
re-initialized, units not converted.

Would someone be so kind as to reply with a script that will, say,
increment a displayed counter every time Submit is clicked? TIA!

--
--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
you need to use self submitting script with a hidden field to submit
everytime you hit submit.

sanjay

"Raptor" <me@attbi.com> wrote in message news:3F************@attbi.com...
| I'm an experienced C/C++ programmer learning PHP.
|
| I'm currently trying to write a simple unit converter script. I thought
| I saw a tutorial somewhere that used isset() to determine whether the
| script is running for the first time, initialize if so, perform the
| usual function otherwise. But my own attempt at this doesn't seem to
| work. Every time I hit Submit, my start-up branch runs, variables are
| re-initialized, units not converted.
|
| Would someone be so kind as to reply with a script that will, say,
| increment a displayed counter every time Submit is clicked? TIA!
|
| --
| --
| Lynn Wallace http://www.xmission.com/~lawall
| "I'm not proud. We really haven't done everything we could to protect
| our customers. Our products just aren't engineered for security."
| --Microsoft VP in charge of Windows OS Development, Brian Valentine.
|
Jul 17 '05 #2

P: n/a
I noticed that Message-ID: <3F************@attbi.com> from Raptor
contained the following:
Would someone be so kind as to reply with a script that will, say,
increment a displayed counter every time Submit is clicked? TIA!


<html>
<head>
<title>Counter</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!$_POST["submit"]){
$counter=0;
}
else{$counter=$_SERVER['QUERY_STRING']+1;
}
?>
<form name="form1" method="post" action="<?php
print"$PHP_SELF?$counter"?>">
<p>Counter = <?php print $counter; ?>
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
</body>
</html>

--
Geoff Berrow
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3

P: n/a
Geoff Berrow wrote:
I noticed that Message-ID: <3F************@attbi.com> from Raptor
contained the following:

Would someone be so kind as to reply with a script that will, say,
increment a displayed counter every time Submit is clicked? TIA!

<html>
<head>
<title>Counter</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!$_POST["submit"]){
$counter=0;
}
else{$counter=$_SERVER['QUERY_STRING']+1;
}
?>
<form name="form1" method="post" action="<?php
print"$PHP_SELF?$counter"?>">
<p>Counter = <?php print $counter; ?>
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
</body>
</html>


Thanks, Geoff!

When I copied/pasted into increment.html, it didn't work worth squat.
Changing the name to increment.php works like a charm. Sigh, I thought
Linux systems ignored filename extensions. Is this some HTTP thing?
(Can you tell I've been programming well below the web level for most of
my career?:-)

--
--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 17 '05 #4

P: n/a
Linux doesn't really care about file extensions that much, but webservers
does.. :p

--
// DvDmanDT
MSN: dv******@hotmail.com
Mail: dv******@telia.com
"Raptor" <me@attbi.com> skrev i meddelandet news:3F************@attbi.com...
Geoff Berrow wrote:
I noticed that Message-ID: <3F************@attbi.com> from Raptor
contained the following:

Would someone be so kind as to reply with a script that will, say,
increment a displayed counter every time Submit is clicked? TIA!

<html>
<head>
<title>Counter</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
if (!$_POST["submit"]){
$counter=0;
}
else{$counter=$_SERVER['QUERY_STRING']+1;
}
?>
<form name="form1" method="post" action="<?php
print"$PHP_SELF?$counter"?>">
<p>Counter = <?php print $counter; ?>
</p>
<p>
<input type="submit" name="submit" value="Submit">
</p>
</form>
</body>
</html>


Thanks, Geoff!

When I copied/pasted into increment.html, it didn't work worth squat.
Changing the name to increment.php works like a charm. Sigh, I thought
Linux systems ignored filename extensions. Is this some HTTP thing?
(Can you tell I've been programming well below the web level for most of
my career?:-)

--
--
Lynn Wallace http://www.xmission.com/~lawall
"I'm not proud. We really haven't done everything we could to protect
our customers. Our products just aren't engineered for security."
--Microsoft VP in charge of Windows OS Development, Brian Valentine.

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.