0

I have a textarea form where you can insert URLs which are passed through a function. But I can't figure out how to secure it against malicious code.

I found a way to check valid characters with preg_match() but since a URL can contain almost every character this isn't very useful.

Is there a way to check if the textarea only contains URLs or disable code execution all together?

0xMB
  • 871
  • 1
  • 8
  • 15
Rob
  • 127
  • 1
  • 2
  • 12

2 Answers2

1

You can use:

$input= htmlspecialchars($_POST['input']);

for example.

MrK
  • 1,060
  • 9
  • 23
0

If you just want to prevent HTML from being passed from the textarea, may be strip_tags can do the job.

Fabien TheSolution
  • 5,055
  • 1
  • 18
  • 30