Mar 2

..continued from The TRUTH about PHP/mySQL security Part I

So here we are on "The TRUTH about PHP/mySQL security Part deux", So after reading lots of websites/blogs and reviewing nearly 100 OS PHP/mySQL scripts I have found that everyone has a similar structure

Main Page
  |- imgs
     |-someimage.jpg
     |-someimage.jpg
  |- inc
     |- dbconnection.php
     |- extra_file.php
     |- extra_file.php
     |- extra_file.php

What we want to look for is the dbconnection.php file. So lets take a look at a simple dbconnection.php file

PHP:
  1. <?
  2. include "../config.php";
  3.  
  4. function db_connect()
  5. {
  6.    $result = @mysql_pconnect($server, $db_user, $db_pass) or die ("Database CONNECT Error (db_fns line 7)")
  7.    if (!$result)
  8.       return false;
  9.    if (!@mysql_select_db($database))
  10.       return false;
  11.  
  12.    return $result;
  13. }
  14.  
  15. ?>

But now we see there is an include config.php, lets take a look into that file

PHP:
  1. <?
  2. $domain  = "www.yourdomain.com"; // Your domain name (include www. if used BUT NOT http://)
  3. $server             = "localhost"; // Your MySQL server address (usually 'localhost')
  4. $db_user            = "username"; // Your MySQL database username
  5. $db_pass            = "password"; // Your MySQL database password
  6. $database           = "database"; // Your MySQL database name
  7. $currency   = "UK Pounds"; // The currency that your affiliates will be paid in
  8. $emailinfo                = "test@email.com"; // Your email address
  9. $yoursitename   = "Your Site Name"; // Your sites name
  10. ?>

Is all this information sensitive? Of course it is! imagine some one getting a hold of your $db_user or $db_pass variable, they could easily create scripts that will log into your DB and either edit the information or destroy it. But I'm not going to go into detail about that, what I am after is to learn how secure it is to leave your php scripts out in the open and from what I have learned so far it is pretty safe do that, but I want to continue to search for what other kind of security is offered by PHP.

...to be continued

Feb 23

So I finished a small application that I am using only on my computer to avoid any problems on the net in regards to security (name it hackers/crackers/enthusiast/whichever).

Since there is no easy way to ask a question like What is the best way to create a secure applicationI decided to send the question out there and ask to what everyone thinks or believes is a secure way to create their applications.

I have been working with PHP/mySQL as user not much as developer for the past years but now trying to learn more about the developer side, I have hit a wall once I have faced Security.

For a while I was certain that putting my sql connection in a PHP file it was ok, this believe was even stronger while using different applications out there that place their connections logarithms inside folders named as simple as connections, and if we want to examine this theory further if you create a Database Connection in Dreamweaver the application itself will create a folder titled Connections and inside that folder it will write the scripts necessary to connect to your DataBase.

With all this in mind I ran into a basic tutorial that highlighted the importance of having your connections secure and one recommendation was to place your connections script (or PHP file) under a password protected directory. This would be an overkill IMHO and not only that but securing a password with another password?

To Be Continued....

May 17

There are times when you just need to pull the default value of a radio button selection, rather than creating and array and testing from it.

The quick and dirty solution is to place a hidden field right before those items you want to send with default values if nothing is selected.

PHP:
  1. <input type="hidden" name="NameOfYourRadio" value="Default Value"/>

Jun 6
PHP Test
icon1 helmut | icon2 PHP | icon4 06 6th, 2003| icon3No Comments »


Hi .
You are years old.