Jump to content

[SOLVED] Problem with puncuation in input form


s1yman

Recommended Posts

Thanks for the info mate.

 

The punctuation confuses the process script when user clicks submit, so I have tried;

<?php
$one = htmlentities($_POST['one'],ENT_QUOTES);
$sql="INSERT INTO Test2 (one)
VALUES
('$one')"; ?>

 

Which strips the code and makes the punctuation stop interfering with the script but still show properly on the display page. The only problem is that I want people to be able to put links and possibly other scripts. Do you know any way to do this?

<?php
$one = mysql_real_escape_string($_POST['one']); //this will escape all characters that can break your query
$one = strip_tags($one, '<a>'); //will remove all html tags except anchors
?>

 

It's not a good idea letting users insert code and then display it to other users. You may end up with exploiters using XSS all the way. It depends on what you want to achieve though, but stripping code is usually a good practice.

Archived

This topic is now archived and is closed to further replies.

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