470,835 Members | 1,811 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,835 developers. It's quick & easy.

(n00b) One script, multiple transactions

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
4 2179
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
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
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
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.

Similar topics

15 posts views Thread by Arnaud | last post: by
11 posts views Thread by Alban Hertroys | last post: by
12 posts views Thread by Berj | last post: by
reply views Thread by MHenry | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.