A Problem with cookies

I have tried to make a login page but i m getting a problem
I think this is bcause of cookie problem

Code of index.html

[php]<?php
$ip=$_SERVER[‘REMOTE_ADDR’];
setcookie(ip,$ip,time()+(60*60),"/");
echo “IP Address= $ip”;
?>

mChat


[/php]

code of index2.html

[php]<?php
$userName=$_POST[“userName”];
$pwd=$_POST[“pwd”];
setcookie(userName,$userName,time()+(6060),"/");
setcookie(pwd,$pwd,time()+(60
60),"/");$cip=$_COOKIE[“ip”];$dip=$_SERVER[‘REMOTE_ADDR’];echo $dip;
if ($cip==$dip) echo ("

yipee
“.$cip.” == “.$dip.”

");
echo (“user=”.$userName."
".“pwd=”.$pwd);
?>

[/php]

Code of login.php

[php]<?php
$userName=$_COOKIE[“userName”];
$pwd=$_COOKIE[“pwd”];

echo ($userName);echo ($pwd);

$con = mysql_connect(“localhost”,“cyberm4_chat”,"********");
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“cyberm4_users”, $con);

$result = mysql_query(“SELECT * FROM users
WHERE userName=’”.$userName."’");

$row = mysql_fetch_array($result);

mysql_close($con);

echo ($userName);echo ($pwd);

similar_text($pwd,$row,$percent);

if ($percent=100) {echo “you are true”.$userName;
echo $userName;
}

?> [/php]

Currently the ip is of no use but it is of much use to me afterwards
Also can anyone of you give me help on making the above secure with https: and md5
I read another post with secure code and md5 but couldn’t make head or tail of it

u can try this code at http://megh.tk/chat/
username=anonymous
password=password

even if i try to enter any other thing it always displays you are true . Why ???

i m looking for help.

Sponsor our Newsletter | Privacy Policy | Terms of Service