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

我的梦境 提交于 2020-01-17 16:37:21

问题


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



来源:https://stackoverflow.com/questions/15574673/serverphp-self-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!