| Web Design and Hosting Creating sites, scripting, and hosting discussions. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Jan 15, 2003
Location: Whangarei, New Zealand
Posts: 2
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: Pwnt
|
I have a simple xhtml page with a form asking for the user's first name, last name, email address and phone number. The form submits its data to 'database.php' which is a simple php script that adds the given data to the table 'entries' in the database 'one'.
At the moment, it's nothing more than that. In the php page I open the connection to the mysql server through a separate script in a subdirectory which will eventually be protected with htaccess. Security is of extreme importance in this situation. What measures can I take to prevent a malicious user entering a set of commands that will close the query and give them full access to my database (eg entering a single/double quote and a ')' to terminate the running command)? I'm in your forums, writing sentences in a grammatically acceptable manner. |
| QUOTE Thanks | |
![]() Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,905
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
|
Verify all data. and what I would do is post to your original page and then send them to a different page saying thank you.
For you login data, make sure that file is kept outside of the web directories that way a person can not access it through the web.. only through ftp, ssh, etc but then they have to have the password.. if they get the password then it really does not matter what kind of security you do.. Try urlencoding and urldecoding.. try stripslashes, try addslashes.. I put all my data into single quotes.. even those that are just numbers.. I do remove the slashes and then add my own slashes to the data.. that should take care of all yoru problems
---> Join the Mac-Forums Folding team: use 37954 as your team number.View Mac-Forums Folding team statistics (More Info) Don't forget to use the User Reputation System |
| QUOTE Thanks | |
![]() Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,905
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
|
---> Join the Mac-Forums Folding team: use 37954 as your team number.View Mac-Forums Folding team statistics (More Info) Don't forget to use the User Reputation System |
||||
| QUOTE Thanks | |||||
![]() Member Since: Jan 15, 2003
Location: Whangarei, New Zealand
Posts: 2
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: Pwnt
|
You mean post to PHP_SELF() or whatever, and have the database script in the same file?
Do single quotes prevent mySQL commands being entered? I think the only way I could even get the form data into the database was to use something like: insert into table values('$first_name', '$last_name') Is that secure, if I use stripslashes with it? I'm in your forums, writing sentences in a grammatically acceptable manner. |
| QUOTE Thanks | |
![]() Member Since: Jan 15, 2003
Location: Whangarei, New Zealand
Posts: 2
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: Pwnt
|
I'm in your forums, writing sentences in a grammatically acceptable manner. |
| QUOTE Thanks | |
![]() Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,905
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
|
Yeah I mean using PHP_SELF.. try to make sure and use the new global variables though.. so $_SERVER['PHP_SELF'] and $_POST['firstname'] etc etc And actually you wont need to do anything to that input because it should automatically add slashes to your incoming data..
So let's say $_POST['lastname'] was O'Connel then it would actually be O\'Connel which escapes the apostrophe.. and tells mysql to not use it as part of the sql statement.. that it's actually part of the value.. So something like this: INSERT INTO tablename VALUES ('{$_POST['firstname']}', '{$_POST['lastname']}'); As you can see, surrounding the variables are single quotes.. now since the data within will have their single quotes escaped.. it shouldnt matter what kind of stuff someone puts in the fields.. they shouldnt be able to add any damaging code, without it throwing up an error. ---> Join the Mac-Forums Folding team: use 37954 as your team number.View Mac-Forums Folding team statistics (More Info) Don't forget to use the User Reputation System |
| QUOTE Thanks | |
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Wi-Fi Security | schweb | Schweb's Lounge | 12 | 05-15-2009 04:31 PM |
| Removing MySQL from Panther 3.6 | vawolf | OS X - Operating System | 0 | 12-07-2004 09:25 PM |
| Apple releases new Panther security update | Murlyn | OS X - Operating System | 2 | 11-04-2003 05:51 PM |
| @Stake issues security advisories for Jaguar | Murlyn | OS X - Operating System | 0 | 10-29-2003 03:31 PM |
| Severe Flash Security Flaw | schweb | Apple Rumors and Reports | 1 | 03-04-2003 01:03 PM |
All times are GMT -4. The time now is 01:12 PM.
Powered by vBulletin