Web Analytics Made Easy -
StatCounter help with simple form php code - CodingForum

Announcement

Collapse
No announcement yet.

help with simple form php code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with simple form php code

    PHP Code:
    <html>
    <head>
    <title> Testing </title>
    </head>
    <body>

    <h2> The BACKWORD: </h2>
    <br>

    <?php
        
            
    if(isset($string))
            {
                for(
    $i strlen($string)-1$i >= 0$i--)
                {
                print 
    $string[$i];
                }
            }
            else
            {
        
    ?>
        <FORM METHOD=POST ACTION="<?php echo $PHP_SELF;?>">
        Enter a word: <INPUT TYPE="text" NAME="string">
        <INPUT TYPE="submit" value="done!">
        </FORM>
    <?php
        
    }
    ?>

    </body>
    </html>

    ok, i need help with the above code. im trying to write a simple php script in which it ask a user for a word in the field textbox. then when the user press 'done!', it will output the user's word backword.

    for some reason, when i press done! it always show the same "Enter a word" stuff.
    Last edited by Extrovertive; Jul 9, 2002, 08:33 PM.

  • #2
    I just tried it and it worked just fine.
    Spookster
    CodingForum Supreme Overlord
    All Hail Spookster

    Comment


    • #3
      weird. testing it offline on my localhost doesnt work. but i when i upload it on my webserver, it works. what's up with that???

      Comment


      • #4
        Originally posted by Extrovertive
        weird. testing it offline on my localhost doesnt work. but i when i upload it on my webserver, it works. what's up with that???
        Same here, when I tried testing it on my localhost I got "HTTP 500 - Internal server error".

        Edit: Any relevance here?: http://www.microsoft.com/serviceprov...To/P118948.asp
        Last edited by boxer_1; Jul 9, 2002, 10:49 PM.
        boxer_1
        CodingForum Moderator
        "How did a fool and his money get together in the first place?"

        Comment


        • #5
          I tested it locally on my machine. I am running firepages phpdev on winXP. What are you running?
          Spookster
          CodingForum Supreme Overlord
          All Hail Spookster

          Comment


          • #6
            try and get used to using the new super_globals arrays
            ......
            PHP Code:
            <?php
                
                    
            if(isset($_POST[string]))
                    {
                        for(
            $i strlen($_POST[string])-1$i >= 0$i--)
                        {
                        print 
            $_POST[string][$i];
                        }
                    }
                    else
                    {
                
            ?>
            .....
            PHP Code:
                <FORM METHOD=POST ACTION="<?php echo $_SERVER[PHP_SELF];?>">

            its a pain but one we are stuck with!

            note to be backwards compatible you need to use $HTTP_POST_VARS[string] etc but the superglobals $_POST, $_GET etc should be available from php4.06+
            resistance is...

            MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

            Comment


            • #7
              thanks a lot firepages. do u know where i can find this on the php usermanual?

              Comment


              • #8


                Also, the superglobals are available since PHP 4.1.0.
                De gustibus non est disputandum.

                Comment

                Working...
                X