$_SERVER['PHP_SELF'] not working [closed]

2019-09-21 20:26发布

问题:

Im sorry if this kind of question has been asked before. but i spent much time searching for but I could not find the solution. so i'm posting here..

Problem: I'm trying to post the values onto the same page(working with Jquery mobile UI). so I'm using $_SERVER['PHP_SELF'] in action for my form in the page. Please check the spelling for action(working for actoin but not for action)

when i'm using this its posting in the same page and i'm happy

<form method="POST" actoin="<?php echo $_SERVER['PHP_SELF'];?>">

Please check the spelling for action

but, when I'm using this <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">

Its pointing to index.php of my application.

can anyone please tell me..why its happening like this..please note that I know that its typo..

Thanks,

回答1:

The problem is $_SERVER['PHP_SELF'] returns the name of script. You probably mean $_SERVER['REQUEST_URI']. It is working with actoin because most of browsers will submit it to the same page when there is no action attribute.



回答2:

action not actoin , and you can simply write

 <form method="post">

without action and it will post values on the same page