(n00b) One script, multiple transactions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Raptor

    (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.

  • s a n j a y

    #2
    Re: (n00b) One script, multiple transactions

    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:3F916D64.1 0101@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.
    |


    Comment

    • Geoff Berrow

      #3
      Re: (n00b) One script, multiple transactions

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

      <html>
      <head>
      <title>Counte r</title>
      </head>
      <body bgcolor="#FFFFF F" 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/

      Comment

      • Raptor

        #4
        Re: (n00b) One script, multiple transactions

        Geoff Berrow wrote:[color=blue]
        > I noticed that Message-ID: <3F916D64.10101 @attbi.com> from Raptor
        > contained the following:
        >
        >[color=green]
        >>Would someone be so kind as to reply with a script that will, say,
        >>increment a displayed counter every time Submit is clicked? TIA![/color]
        >
        >
        > <html>
        > <head>
        > <title>Counte r</title>
        > </head>
        > <body bgcolor="#FFFFF F" 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>[/color]

        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.

        Comment

        • DvDmanDT

          #5
          Re: (n00b) One script, multiple transactions

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

          --
          // DvDmanDT
          MSN: dvdmandt@hotmai l.com
          Mail: dvdmandt@telia. com
          "Raptor" <me@attbi.com > skrev i meddelandet news:3F91D991.3 0702@attbi.com. ..[color=blue]
          > Geoff Berrow wrote:[color=green]
          > > I noticed that Message-ID: <3F916D64.10101 @attbi.com> from Raptor
          > > contained the following:
          > >
          > >[color=darkred]
          > >>Would someone be so kind as to reply with a script that will, say,
          > >>increment a displayed counter every time Submit is clicked? TIA![/color]
          > >
          > >
          > > <html>
          > > <head>
          > > <title>Counte r</title>
          > > </head>
          > > <body bgcolor="#FFFFF F" 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>[/color]
          >
          > 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.
          >[/color]


          Comment

          Working...