Tag Archives: PHP
Add Password Encryption to a Dreamweaver Registration Form
Adding password encryption to a Dreamweaver registration form is even easier than adding encryption to a Dreamweaver login form. Much like changing the Dreamweaver login form to add encryption, changing the registration form will also cause an error (according to Dreamweaver) but regardless this method should work just fine. After inserting the code mentioned below you should not attempt to modify this registration script via the insert record dialog provided by Dreamweaver. Instead, edit the code manually when making changes.
Example code snippet:
$insertSQL = sprintf("INSERT INTO users (username, password) VALUES (%s, %s)"
Change your code to add “sha1″ or “md5″ depending on what type of encryption you wish to use:
$insertSQL = sprintf("INSERT INTO users (username, password) VALUES (%s, sha1(%s))"
Add Password Encryption to a Dreamweaver Login Form
With two simple changes you can add password encryption to your Dreamweaver login form. Dreamweaver will consider this an error and display two login user behaviors but regardless this method should work just fine. After inserting the code mentioned below you should not attempt to modify this login script via the log in user dialog provided by Dreamweaver. Instead, edit the code manually when making changes.
Right after the line of code:
$password=$_POST['password'];
Add this:
$encrypt_password=sha1($password);
You can add whatever type of encryption you would like in place of sha1.
Change this bit of code:
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
Replace $password with $encrypt_password:
GetSQLValueString($loginUsername, "text"), GetSQLValueString($encrypt_password, "text"));
Conclusions: When sending password data over the internet it is always important to encrypt it. In case anyone hacks your server and reads the password database this is a safety net. Providing how simple this is to change I would have thought Adobe would have built this into Dreamweaver. We can probably expect this in a future release.
Making the Connection- MySQL Join
For a project I was working on I needed to pull information from two database tables with a common ID. A more static method I had used a few times over was simply posting information such as the user’s name in the ‘posts’ database every time a new post is created. The problem with this method is that if user information is changed old information entered in the the ‘posts’ database stays unchanged. The solution, MySQL Join!
Convert Comma Separated Values to Links with PHP/MySQL
I’m displaying a list of tags on my site which are formatted as Comma Separated Values (CSV) for every post. Example above.
The CSV tags are stored in the MySQL database as one long string. I wanted to make each tag a link that goes to the search page.
Example: search.php?tag=robots
I found that I can explode the CSV into an array to split it up, then print out the list which basically gives me what I started with. What I had problems with is formatting the array to add the links. That’s where this link from php.net became handy.
http://us2.php.net/manual/en/function.implode.php#83464