Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 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; 07-10-2002 at 01:33 AM.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I just tried it and it worked just fine.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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???

  • #4
    Regular Coder
    Join Date
    May 2002
    Location
    Maine, USA
    Posts
    573
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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; 07-10-2002 at 03:49 AM.
    boxer_1
    CodingForums Moderator
    "How did a fool and his money get together in the first place?"

  • #5
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    I tested it locally on my machine. I am running firepages phpdev on winXP. What are you running?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #6
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    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)

  • #7
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks a lot firepages. do u know where i can find this on the php usermanual?

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.php.net/manual/en/languag...predefined.php

    Also, the superglobals are available since PHP 4.1.0.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •