Date: 02/06/09 (WebDesign) Keywords: php, database I know. I'm such a noob. I've been looking everywhere online for just a simple login and logout code.. I did find one but now it seems to only work for show. Whether I'm logged in or out it doesn't recognize it either way. It does, however, connect to the database at least and will recognize username and password. Login ?> Login: newsession: //error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR); $session['userid']=session_id(); $session['username']=$name; //echo $session['username']; ?> session: session_start(); session_register("session"); ?> loginck: include "include/session.php"; $dbservertype='mysql'; $servername='xxxx.perfora.net'; // username and password to log onto db server $dbusername='xxxx'; $dbpassword='xxxx'; // name of database $dbname='xxxx'; //////////////////////////////////////// ////// DONOT EDIT BELOW ///////// /////////////////////////////////////// connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } ////////////////////////////// ?> $userid=mysql_real_escape_string($userid); $name=mysql_real_escape_string($name); $password=mysql_real_escape_string($password); if($rec=mysql_fetch_array(mysql_query("SELECT * FROM Signup WHERE username='$username' AND Password = '$password'"))){ if(($rec['username']==$username)&&($rec['Password']==$password)){ include "include/newsession.php"; echo "
print ""; } } else { session_unset(); echo "Wrong Login. Use your correct Name and Password and Try } ?> What am I doing wrong? ;_; this is the only thing keeping me from putting my site up... I hope my problem makes sense -_- Source: http://community.livejournal.com/webdesign/1470111.html
|