Jump to content

php form validation question


hariskar

Recommended Posts

In this example if I put in the fields: <script>location.href('http://www.hacked.com')</script> , it gives as my input:

 

<script>location.href('http://www.hacked.com')</script>
hariskar@gmail.com
<script>location.href('http://www.hacked.com')</script>
<script>location.href('http://www.hacked.com')</script>

 

Since there is htmlspecialchars() here

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;

shouldn't it return HTML escaped code?

 

Also since we have htmlspecialchars() in function test_input mentioned above, why do we also have htmlspecialchars() in form action:

action="<?php echohtmlspecialchars($_SERVER["PHP_SELF"]);?>"

?

Couldn't we put something like this as form action:

action="form-page.php"

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...