Jump to content

[SOLVED] Keeping your site secure from users


Grego

Recommended Posts

I've got textareas for my users to input descriptions etc into. The problem is that when they enter HTML or PHP code, it comes out like that, which means they could potentially access the database and mess around with the page.

 

How can I keep my pages secure when displaying this text. IE: How can I make it actually say on screen: "Hello, I'm <strong>Grego</strong>" rather than "Hello, I'm Grego"?

Well i think they could use stuff like SELECT FROM or DELETE FROM

 

in my code i use this

 

on submit

<?php
$original = $_POST['message'];
$original = strip_tags($original);
$original = htmlentities($original, ENT_QUOTES);
?>

 

and then to get it back

 

<?php
$text = $_POST['original'];
$text = mysql_real_escape_string($text);
$text = stripslashes($text);
?>

 

That might cause some problems, but it should be fine ;D

 

~ Chocopi

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.