note 42825 added to function.addslashes

From: Date: Mon, 31 May 2004 03:03:52 +0000
Subject: note 42825 added to function.addslashes
Groups: php.notes 
Request: Send a blank email to php-notes+get-70327@lists.php.net to get a copy of this message
When echoing HTML forms I used to do things like: echo ("<input type='text' name='meh' value='$meh'>"); This leads to problems, however, because any string that contains an apostrophe ( ' ) will mess up the form's data. This also become problematic when trying to incorporate Javascript in the forms, as well. I've just figured out an easy way to fix this, and it's not too entirely messy: echo ("<input type=\"text\" name=\"meh\" value=\"$meh\">"); It might take a bit of getting used to adding a couple of extra keystrokes, but I find it to be well worth the effort. You don't have to worry about apostophes within values when doing it this way. The slashes and double-quotation marks ( " ) probably don't really need to be there when you're not dealing with strings (you could just use a single ( ' ) instead), but by doing this slashing process to everything it keeps things consistent. ---- Manual Page -- http://www.php.net/manual/en/function.addslashes.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42825 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42825&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42825&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70327) next »