Jump to content

A question about $_SERVER["PHP_SELF"]


phppup

Recommended Posts

Are these two pieces of code equal in risk?

<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
  
  and
  
<form method="post" action="">

Do they perform the same action?

Are both vulnerable? Best practice to minimize vulnerability?

Will using prepared statements nullify a hacking attempt?

I was doing some reading and thought I'd ask the experts here.

Link to comment
Share on other sites

Omitting the action attribute from a form tag is the current best practice, yes. As far as data/form security goes, it takes more than just that - it takes things like using a nonce and validating and sanitizing any user-submitted data before you do anything with it. Even then, you'll need to use prepared statements for any database interactions that involve said user-submitted data.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.