Jump to content

Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.