Any good soul want to clean this code ??? I Get a lot of errors
(Username1 and Password1 are posted by a separate form and function_connect.php includes database connection. I saw it on a tutorial but couldn't make it work ....
PHP Code:
<?php
$username1 = $_POST['user'];
$password1 = $_POST['pass'];
include "function_connect.php";
// valid login credentials
if ($username1 && $password1) {
$sql="SELECT id, username, password FROM pointgather WHERE
username='$username1' AND password='$password1'";
$result = mysql_query ($sql) or die('Error: ' . mysql_error());
$user_data = mysql_fetch_array ($result);
$id = $user_data ['id'];
$username = $user_data ['username'];
$password = $user_data ['password'];
first thing I noticed is that you are not checking if the user name existed or not !? you just assigned ID,user and password to cookie !
and then you are using MD5() to encyrpt the username ?? why ? also it is recommended to encrypt the password in database not in cookie !! not to mention it's a security risk to store the password in a cookie ..
__________________ PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
can you please post the errors here, so it is easier for us to check what might be wrong? we can not test this code on our local system since we don't have your full system that this is a part of.
I took a look at your script an it looks like it would work depending on the version and configuration of your php.
I sugguest that you check your
phpinfo()
to see how yours is setup and version you are using.
And if your uploading this to a different server know it's PHP information and setup.