Current location: Hot Scripts Forums » Programming Languages » PHP » Sanitizing data

Sanitizing data

Reply
  #1 (permalink)  
Old
Wannabe Coder
 
Join Date: Jul 2010
Posts: 137
Thanks: 2
Thanked 0 Times in 0 Posts
Sanitizing data

Hi guys i am trying to sanitizing the data entry.. but for some reason it does not happen... help

PHP Code:

<?php


$galleria_id
=$_POST['cat'];

   if (isset(
$_POST['name'])) {
   
   
$name=sanitize($_POST['name']);
   
$texto=sanitize($_POST['texto']);

   }



   
$query "INSERT INTO eventogaleria (galleria_id,name,texto)" .
            
" VALUES ('$galleria_id','$name','$texto')";
            
            

   
$result mysql_query($query) or die('Unable to add product');
   if (
$result)

      echo 
"<h2>Una Nueva Foto ha sido anadida al album</h2>\n";
      
   else

      echo 
"<h2>Ha habido un problema andaidiendo tu foto.</h2>\n";
?>
sanitize data function

PHP Code:



<?php
function sanitize($data)
{
// remove whitespaces (not a must though)
$data trim($data);

// apply stripslashes if magic_quotes_gpc is enabled
if(get_magic_quotes_gpc())
{
$data stripslashes($data);
}

// a mySQL connection is required before using this function
$data mysql_real_escape_string($data);

return 
$data;
}
?>

thanks
Reply With Quote

Featured Marketplace Scripts (view more)

  #2 (permalink)  
Old
DanielVS's Avatar
Newbie Coder
 
Join Date: Jan 2010
Location: Vancouver, BC, Canada
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Seems right. But is happening that should not be happening, or what is not happening that should be happening? Say that five times fast =)
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:11 PM.
vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.