...

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



shlagish
04-29-2004, 12:17 AM
here is the relevant 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:



$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?

celestine
04-29-2004, 04:11 AM
maybe it has something to do with the double echo ?

try:

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

raf
04-29-2004, 07:34 AM
or replace

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

by


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

shlagish
04-29-2004, 10:21 PM
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 :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum