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 4 of 4
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts

    $_SERVER["PHP_SELF"] becomes %3C: why?

    here is the relevant code:
    PHP Code:
      $yo = $_SERVER["PHP_SELF"];
      echo($yo);
      echo("
    <form action='<?php echo($yo); ?>' method='get'>
    <input type='text' name='sender' /><input type='submit' value='Join the chat' />
    </form>
      ");
    the file is http://localhost/chat1.php
    when I click on the submit button, it becomes:
    http://localhost/%3C?sender=shlagish
    what I want it to be is:
    http://localhost/chat1.php?sender=shlagish

    why does $yo become %3C instead of staying at $_SERVER["PHP_SELF"] ?
    also, if I use this:

    PHP Code:
      $yo = "/chat1.php";
      echo($yo);
      echo("
    <form action='<?php echo($yo); ?>' method='get'>
    <input type='text' name='sender' /><input type='submit' value='Join the chat' />
    </form>
      ");
    it does the same thing and brings me to:
    http://localhost/%3C?sender=shlagish

    what am I not getting here?
    Shawn

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    112
    Thanks
    0
    Thanked 0 Times in 0 Posts
    maybe it has something to do with the double echo ?

    try:
    Code:
    echo("
    <form action=\"$yo\" method='get'>

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    or replace

    $yo = $_SERVER["PHP_SELF"];
    echo($yo);
    echo("
    <form action='<?php echo($yo); ?>' method='get'>

    by
    PHP Code:
    echo('<form action="'$_SERVER["PHP_SELF"] .'" method="get">
    ...'
    ); 
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    hmm, that works of course, I don't know why I was using a double echo... I guess I'm just not used to PHP yet...
    Thanks for the reply
    Shawn


  •  

    Posting Permissions

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