Page 1 of 1
<form action="<?=$PHP_SELF;?>" method="get"> does not work
Posted: Tue Apr 21, 2009 8:22 am
by jdmfontz
Wondering why "<?=$PHP_SELF;?>" does not seem to be working for me on this particular server. On other installations it works fine. Is there a PHP configuration parameter I don't know about that need to set?
<h1> Search v2.1</h1>
<p>
<form action="<?=$PHP_SELF;?>" method="get">
<p>
Select Protocol/Apps: <select name="apps">
<option value=" ">Choose</option>
<option value="http">HTTP</option>
<option value="dns">DNS</option>
...
Thank you in advance.
Re: <form action="<?=$PHP_SELF;?>" method="get"> does not work
Posted: Tue Apr 21, 2009 9:21 am
by papa
TRy
Code: Select all
<?php echo $_SERVER['PHP_SELF']; ?>
Re: <form action="<?=$PHP_SELF;?>" method="get"> does not work
Posted: Tue Apr 21, 2009 9:22 am
by requinix
Actually, use SCRIPT_NAME. Using PHP_SELF opens yourself up to various attacks.
Code: Select all
<?php echo $_SERVER['SCRIPT_NAME']; ?>
$PHP_SELF was created automatically because of register_globals. Which is a bad thing so don't use it.
Re: <form action="<?=$PHP_SELF;?>" method="get"> does not work
Posted: Tue Apr 21, 2009 1:06 pm
by jdmfontz
Hmm, this works good. Wondering why my other syntax (<form action="<?=$PHP_SELF;?>" method="get">
) worked in one case but not in another...
Even tried <form action="<?php =$PHP_SELF;?>" method="get">
Re: <form action="<?=$PHP_SELF;?>" method="get"> does not wo
Posted: Tue Apr 21, 2009 1:21 pm
by McInfo
Question:
jdmfontz wrote:Wondering why my other syntax (<form action="<?=$PHP_SELF;?>" method="get">
) worked in one case but not in another...
Answer:
tasairis wrote:$PHP_SELF was created automatically because of register_globals. Which is a bad thing so don't use it.
Clarification:
When $PHP_SELF is set, register_globals (in php.ini) is on. When only $_SERVER['PHP_SELF'] is set, register_globals is off.
Edit: This post was recovered from search engine cache.
Re: <form action="<?=$PHP_SELF;?>" method="get"> does not work
Posted: Tue Apr 21, 2009 1:30 pm
by requinix
jdmfontz wrote:Even tried <form action="<?php =$PHP_SELF;?>" method="get">
The =$var method (echo's "short(cut) syntax") only works with short tags. So
will actually throw an error.