Is is neccessary to use the following?
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>
Why not <form method="post" action=""> ?
Can someone hack action="" ?
1 Answer 1
The action attribute isn't required in this case, only if you were to keep the method's script within another file for example.
I'm not sure what you mean by "Can someone hack action=""" but this has nothing to do with things being hacked, as long as you validate the user input of the post and such you should be fine.
Sign up to request clarification or add additional context in comments.
1 Comment
Dre_Dre
I see from some sites that If "PHP_SELF" is used in your page then a user can enter a slash (/) and then some Cross Site Scripting (XSS) commands to execute. See this link: html-form-guide.com/php-form/php-form-action-self.html
default
action=""?htmlspecialchars()were omitted, then that would be a different ballgame.<form method="post">? You don't have to specify an action at all, not evenaction="".