archonis Posted January 2, 2010 Share Posted January 2, 2010 Im using a login script that i can not get it to work to save my life. Sometimes it says its there then other times I get a 404. If i leave to username set to username and password set to password i get a login error as i should. If i type is a true username and a true password, opps 404. I just dont get it. Here is my login.php code, <form name="form1" method="post" action="checklogin.php"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"> <?php if ($myusername == "") { ?> <input name="myusername" type="text" id="myusername" value="Username" size="15" /> <input name="mypassword" type="password" id="mypassword" value="password" size="15" /> <input type="submit" name="Submit" value="Login" /> <?php } else { echo "Welcome back " . $myusername; } ?> </div></td> </tr> <tr> <td><div align="center"> <?php if ($myusername == "") { ?> • <a href="lostusernameandpassword.php">Forgot Password</a> • <a href="signup.php">New User</a> • <?php } else { echo "<a href=\"#\">Logout</a>"; } ?> </div></td> </tr> </table> </form> This is my checklogin.php code. <?php ini_set("session.cookie_domain"," .mytowndate.com"); session_start(); $host="localhost"; // Host name $username="*******"; // Mysql username $password="********"; // Mysql password $db_name="trevors4_MTD"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $myusername = $_POST ['myusername']; $mypassword = $_POST ['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); $count = mysql_num_rows ($result); if($count ==1) { session_register ("myusername"); session_register ("mypassowrd"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> Now my login_sussece.php <? ini_set("session.cookie_domain"," .mytowndate.com"); session_start(); $pagetype = "blog" $myusername = $_SESSION['myusername']; $mypassword = $_SESSION['mypassword']; if ($pagetype == 'blog') { $host="localhost"; // Host name $dbusername="**********"; // Mysql username $password="********"; // Mysql password $db_name="trevors4_MTD"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$dbusername", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $date = date("Y-m-d"); mysql_query("UPDATE members SET online = '$date' WHERE username='$myusername'") or die(mysql_error()); // Make a MySQL Connection $query = "SELECT * FROM members WHERE username = '$myusername'"; $result = mysql_query($query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); // If this does not work lets use SSID if ($row['school'] == '') { $fname=$row['fname']; $lname=$row['lname']; $email=$row['email']; $age=$row['age']; $city=$row['city']; $state=$row['state']; $zip=$row['zip']; $gender=$row['gender']; $herefor=$row['herefor']; $showmyphoto = "myphoto.jpg"; header("Location: http://www.mytowndate.com/updateprofile.php?username=".$username."&password=".$password."fname=".$fname."&lname=".$lname."&email=".$email."&age=".$age."&city=".$city."&state=".$state."&zip=".$zip."&gender=".$gender."&herefor=".$herefor); } header("Location: http://www.mytowndate.com/cp/inbox.php?sid=".session_id()); } else { echo "There was an ERROR! OPPS!"; echo $pagetype; } ?> <html> <body> <? echo $pagetype; echo $username; echo $password; ?> Login Successful </body> </html> Link to comment https://forums.phpfreaks.com/topic/186947-file-cant-be-found-its-there/ Share on other sites More sharing options...
rajivgonsalves Posted January 2, 2010 Share Posted January 2, 2010 are you sure your login_success.php exists in the same directory as login.php ? Link to comment https://forums.phpfreaks.com/topic/186947-file-cant-be-found-its-there/#findComment-987212 Share on other sites More sharing options...
mikesta707 Posted January 2, 2010 Share Posted January 2, 2010 well your header is going to login_success.php while you said the page was called login_sussece.php. Idk if that was a typo, but obviously there is something wrong with the header Link to comment https://forums.phpfreaks.com/topic/186947-file-cant-be-found-its-there/#findComment-987215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.