Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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