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
  • 861
  • 1
  • 8
  • 15
Rob
  • 93
  • 2
  • 8

2 Answers2

1

You can use:

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

for example.

KristianH
  • 996
  • 8
  • 20
0

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

Fabien TheSolution
  • 4,950
  • 1
  • 17
  • 29