KYKK Posted June 13, 2008 Share Posted June 13, 2008 Hi use I have a database ksclans_GAME i check if it connect and it ck....and here the code <html><body><?phprequire_once 'db.php';$page_mode = isset($_POST['page_mode']) ? $_POST['page_mode'] : '';$error_string = '';if ($page_mode == 'login'){$name = $_POST['name'];$password = $_POST['password'];if (trim($name) == '' || trim($password) == '')$error_string .= 'Please enter your name and password.<br>';else{$result =("SELECT name, password FROM users");if ($row['password'] != ($password))$error_string .= 'The password did not match.<br>';else{$_SESSION['user_password'] = $row['password'];$_SESSION['user_name'] = $row['name'];{if ($row['password'] = ($password))setcookie('user', 'name', time()+86400, '', 'ksbsm.co.cc');}if ($row['password'] = ($password))echo "Hello World";}exit();}}?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><body><div class="error_text"><?php echo $error_string; ?></div><form action="login2.php" method="post"><input type="hidden" name="page_mode" value="login"><div class="left_box">name</div><divclass="right_box"><input type="text" name="name" size="30"maxlength="255" value=""></div><div class="left_box">Password</div><div class="right_box"><input type="password" name="password" size="40"></div><div class="left_box"> </div><div class="right_box"><input type="submit" value="Log In" size="40"></div><?phpecho $_COOKIE["name"];?></form></body></html> and here my question,,<?phpecho $_COOKIE["name"];?>if ($row['password'] = ($password))setcookie('user', 'name', time()+86400, '', 'ksbsm.co.cc');do i set echo name ? or user but anyway, so it won't show the echo name or user i try both... and it show no form after i put in name and pass to "login" ...but it show the Hello before (like a new PC go to the page) i put in and after i put in there only the Hello left no formpwhy ? I set if ($row['password'] = ($password)) then echo but it still echo ?? Link to comment Share on other sites More sharing options...
Synook Posted June 14, 2008 Share Posted June 14, 2008 The first parameter is the cookie's name, the second the value.By the way are you sure you don't mean if ($row['password'] == ($password)) ? Link to comment Share on other sites More sharing options...
KYKK Posted June 14, 2008 Author Share Posted June 14, 2008 yse it mean the password is right....right?if ($row['password'] != ($password))$error_string .= 'The password did not match.<br>';else{///so if password is wrong then if ($row['password'] = ($password))setcookie('user', 'name', time()+86400, '', 'ksbsm.co.cc');}///if it right then set cookieif ($row['password'] = ($password))echo "Hello World";}///if it right then say something....______________________________________________________________________________when i waiting i read...http://w3schools.invisionzone.com/index.php?showtopic=12509and here what it should after i "login"Fatal error: Call to undefined function db_query() in /home/ksclans/public_html/login1.php on line 19and this line 19 $result = db_query("SELECT id, name, password FROM users WHERE email='" . mysql_real_escape_string($email) . "'");what that mean and what is the problem ? Link to comment Share on other sites More sharing options...
Synook Posted June 15, 2008 Share Posted June 15, 2008 what that mean and what is the problem ?db_query is a custom function, you have to define it or else just use mysql_query().yse it mean the password is right....right?Currently you are using the assignment (=) operator, not the equality (==) one. Link to comment Share on other sites More sharing options...
KYKK Posted June 15, 2008 Author Share Posted June 15, 2008 nvm i solve my problem Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.