Hi, my friend made me some php scripts to go onto my site but the probelm is that they dont work.
The main one i want working si the login script. I have been working on it for a day but having no knowledge of php its very hard to understand. And now he has given up.
There are 3 pages to the login script, one is on my main file (header.php i use headres and footers for my site.) and the code is:
<?php
if (isset($_COOKIE['LoggedIn'])) {
echo("You are logged in as "); echo $_COOKIE['username']; }
else {
echo("Please Login");
include("login.html");
?>
<a href="reg.php" >Register</a>
<?php
}
?>
login.html is a basic form which calls the username "name" and the password "password"
then i have login2.php which is supposed to cheak the info entered against the database and then set a cookie. but i have fucked it up alot so i would appreciate if you didnt joke about.
<?php
include("common_db.inc");
if(!($link_id = mysql_connect($host , $user, $pass))) die(mysql_erorr());
mysql_select_db($dbname);
$sql = "SELECT ID FROM " . user . " WHERE Name='" . addslashes($_POST['Name']) . "' AND Password='" . md5($_POST['Password']) . "' LIMIT 1";
if(!($result = mysql_query($sql))) die(mysql_error());
if(mysql_num_rows($result) == 1) {
} else {
echo "Login failure";
}
?>
i am pretty sure its the login 2 that is messing it up. if you could would you please tell me what to do or if you wnat type it our for me so all i have to do is copy and paste. and also it isnt a problem with the common.db.inc because it connects fine. Oh and i know that its not setting the cookies right. 😃 so if you coukld tell me how to do that and where to put it that would be very helpfull. And if you want contact me on msn or aim or even pm me. i am in desperate need of help.
thanks for your help in advance