[Solved] $_SERVER[‘PHP_SELF’] not working [closed]

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..

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

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..


Solution #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.

Respondent: Developer

Solution #2:

action not actoin , and you can simply write

 <form method="post">

without action and it will post values on the same page

Respondent: Jan Tojnar

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.