Adobe Dreamweaver Forums



Last 10 THreads :         RoboHelp & Knowledge Bases (Last Post : lmarden - Replies : 2 - Views : 3 )           »          catching errors from remotely invoked processes (Last Post : Amy Blankenship - Replies : 3 - Views : 4 )           »          A question for the gurus (Last Post : Amy Blankenship - Replies : 1 - Views : 2 )           »          Naming Layers CS4 Mac (Last Post : Type & Art - Replies : 0 - Views : 1 )           »          Flash CS4 on Windows 2003? (Last Post : Richard Morey - Replies : 0 - Views : 1 )           »          Where are the fonts located? (Last Post : Mike Blaustein - Replies : 1 - Views : 2 )           »          Help with Spry Paged View (Last Post : Skinwehr - Replies : 0 - Views : 1 )           »          ANN: Contact Form Solution Pack (Last Post : A.Translator - Replies : 8 - Views : 9 )           »          Help posting folder to server (Last Post : Alan - Replies : 1 - Views : 2 )           »          Screens get distorted (Last Post : Captiv8r - Replies : 4 - Views : 5 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Dreamweaver: Main > Dreamweaver Application Development
 
Tags: , ,



Reply
  #1 (permalink)  
Old 04-13-2008, 02:51 AM
patricktr
 
Posts: n/a
Diggs:
Default Writing names with apostrophes to the db

Can someone give me some advice please as I am slightly confused about being
safe when dealing with user input via a form.

The scenario is trying to save a name with an apostrophe..

to get this picked up in my validation I had to put an escape character in the
mask ... ereg("^([a-zA-Z \'-]+). I also wanted to make sure any extra spaces in
the input were removed ...

$contact_name = trim($_POST['contact_name']);
$name_parts = explode(' ', $contact_name);
$contact_name = trim(implode(' ', $name_parts));

if (!ereg("^([a-zA-Z \'-]+){5,10}$", $contact_name))
$contact_name = stripslashes($contact_name);
$contact_name = mysql_real_escape_string($contact_name);
$cn_html = htmlentities($contact_name);
{ $errors [] = 'Enter valid contact name: ' . $contact_name . ' ' .
$cn_html; }

The things is when you view an name with an apostrope it is supplemented with
an escape character which I don't believe you would want to commit to the db
.... e.g. if I enter John O'Rei?ly in the above example I get ...

Enter valid contact name: John O\'Rei?ly John O\'Rei?ly

i.e both mysql_real_escape_string & htmlentities give me the same result ....
does this imply that John O\'Reilly would be written to the db if I had entered
John O'Reilly ?

Doesn't seem right.

Any advice much appreciated.
Regards.
Patrick.




Reply With Quote
Sponsored Links
Reply


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

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



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 07:55 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk