1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Text to output:

Discussion in 'PHP' started by soapbath, May 30, 2005.

  1. #1
    Hey! Im back and want more babies!. Erm.. Anyhow. What I need to do this time round is make a input box and then if the user types the same text as a var it prints something like 'well done!'

    So say the var is "Hello"

    The user types "Pie" and php prints:
    "Sorry that is wrong"
    Then the user types "Hello", php prints:
    Thats correct!

    Okey, Hope you understand what I mean.
     
    soapbath, May 30, 2005 IP
  2. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll need to do a form for this. Here's a two file solution. It can also be done easily enough in one file Try this in a file called 'enter.php'

    
    <form action="check.php" method="post">
    <input type="text" value="" name="text_var" size="15">
    <input type='submit' name="updatebtn" value="Check Value">
    </form>
    
    Code (markup):
    and then this in a file called 'check.php
    
    <?php
      if (isset($_POST['text_var']))
      {
        // if the user has entered some text
        $text_var= $_POST['text_var'];
      }
      else
      {
        $text_var='';
      }
      if (strcmp($text_var,"Hello")==0)
      {
        echo "That's correct!";
      }
      else
      {
       echo "That's not correct.";
      }
    ?>
    
    Code (markup):
     
    mnemtsas, May 30, 2005 IP
  3. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, here's a one file solution-

     
    kc3, May 30, 2005 IP
  4. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I like your solution better :p
     
    mnemtsas, May 30, 2005 IP
  5. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    lol, thanks, I started programming this way on a project I've been working on for a while. It's a complete re-design of FindMyWebHost.org. It'll be a lot better than FindMyHosting.com I can assure that, lol, just wait.
     
    kc3, May 30, 2005 IP
  6. mnemtsas

    mnemtsas Super Dud

    Messages:
    497
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    0
    #6
    All of my stuff is done in one file, I just cut and pasted some code I already had that was in two files, that's all. It's a much nicer way of doing it, but makes for some ugly and hard to read code all in one file.
     
    mnemtsas, May 30, 2005 IP
  7. kc3

    kc3 Peon

    Messages:
    857
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yeah, that's true but it saves how many files you have. I have many things in one file but if they're related to a similar function such as to manage users, if not I use different files.
     
    kc3, May 30, 2005 IP