Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Form page acting funny!

  1. #1
    Join Date
    Sep 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Form page acting funny!

    Hey, can anybody tell me why this scrip isn't working? I'm sure the code is right, but when the page is opened in a browser, the php code is filled it the text field. Also the php code shows up in the html source code (?). I'm using Wordpad as my text editor and saving my files as text files with a .php extention (my_file.php). Can anyone help?


    <body>
    <h1>Reverse String</h1><hr />
    <?php
    if (!isset($_GET['input_text']))
    echo "<p>Enter the string you want to reverse.</p>";
    else{
    $ForwardString = $_GET['input_text'];
    $ReverseString = strrev($ForwardString);
    echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
    }
    ?>
    <form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
    <p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
    <p><input type="submit" value="Reverse String" /></p>
    </form>

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Do you have a link to the page?
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Sep 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

  4. #4
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    You might want to check with your host to make sure it supports PHP.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Indeed, this looks that that is the case. If they say they do support PHP, make a new file called info.php and place this in it:

    Code:
    <?php
     phpinfo();
    ?>
    if you get a blank page, then they are lying. Otherwise, further troubleshooting will be required.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Sep 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That's what I thought at first. But my previous and simpler scrips were working fine. I already contacted my web host (Bravenet) and the said PHP was working fine. I also tried the code on another server (Go Daddy) and got the same results...the simpler scrips work but the ones with forms don't. This is really gettin' frustrating!

  7. #7
    Join Date
    Sep 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Btw, I DID try the code you gave me and it worked. I got to the PHP info page.

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Ok, then you will need to post the entire code for the page so that we can see what is the cause of your problem. Be sure to remove any usernames and passwords.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  9. #9
    Join Date
    Sep 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I really appriciate you checking it out!
    Here's my code:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Logical Examples</title>
    </head>
    <body>
    <h1>Reverse String</h1><hr />
    <?php
    if (!isset($_GET['input_text']))
    echo "<p>Enter the string you want to reverse.</p>";
    else{
    $ForwardString = $_GET['input_text'];
    $ReverseString = strrev($ForwardString);
    echo "<p>'$ForwardString' spelled backwards is '$ReverseString'.</p>";
    }
    ?>
    <form action="ReverseString.php" method="get" enctype="application/x-www-form-urlencoded">
    <p><input type="text" name="input_text" size="20" value="<?php if (!empty($_GET['input_text'])) echo $_GET['input_text'] ?>" /></p>
    <p><input type="submit" value="Reverse String" /></p>
    </form><hr />
    </body>
    </html>

  10. #10
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    I can't figure it out. I used the code you posted and it worked perfectly on my servers. I didn't modify anything and it worked fine; so that means the code is code (other than the XHTML standard you are using; which Twey can explain more about this). As for the PHP, there is nothing wrong with it as I tested on several servers and it worked fine.

    Sorry I couldn't be of more help.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

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