ssk1712 0 Newbie Poster

where do i place this code.im confused?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<LINK href="special.css" rel="stylesheet" type="text/css">
<title>User Info</title>



<STYLE type="text/css">
.htmlForm td{
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:12px;
    color:#CC3300;
    border-bottom:1px #EAE3C8 solid;
}
.htmlForm input,select{
    border:1px #BDB597 solid;
    font-family:tahoma;
    font-size:12px;
    padding:2px;
}
.points{
    font-family:tahoma;
    font-size:11px;
    color:#CC3300;
    padding-left:20px;
    padding-top:20px;
}
.points li{
    padding-top:5px;
}
.formHeading{
    font-family:Arial, Helvetica, sans-serif;
    font-size:16px;
    font-weight:bold;
    color:#CC3300;
    padding:10px;
}
</style>

</head>

<body>
	
	<?php

      session_start();
    // set timeout period in seconds
   $inactive = 600;
    // check to see if $_SESSION['timeout'] is set
   
      if(isset($_SESSION['timeout']) ) {
   
      $session_life = time() - $_SESSION['timeout'];
   
      if($session_life > $inactive)
  
      { session_destroy(); header("Location: logoutpage.php"); }
  
      }
  
      $_SESSION['timeout'] = time();
?>		
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC" class="formHeading">
<tr>
<form name="form1" method="post" action="../sessions1/checklogin.php">
<td>
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td colspan="3"><strong>Member Login </strong></td>
</tr>
<tr>
<td width="78">Username</td>
<td width="6">:</td>
<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input name="mypassword" type="text" id="mypassword"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td><input type="submit" name="Submit" value="Login"></td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</body>
</html>

This is my login_success page

<?
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
}
 ?>
<?php

      session_start();
    // set timeout period in seconds
   $inactive = 600;
    // check to see if $_SESSION['timeout'] is set
   
      if(isset($_SESSION['timeout']) ) {
   
      $session_life = time() - $_SESSION['timeout'];
   
      if($session_life > $inactive)
  
      { session_destroy(); header("Location: logoutpage.php"); }
  
      }
  
      $_SESSION['timeout'] = time();


?>

<html>
<body>
<table align="center">
<tr align="center">
<td align="center">
Login Successful
<br/> 
<a href="logout.php"><b>Logout</b></a>
</td>
</tr>
</table>


</body>
</html>

wait im placing the complete code then you tell how to I do it?

This is my checklogin page.

<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="members"; // Database name
$tbl_name="test	"; // 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");

// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword");
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}

?>
<?php


      session_start();
    // set timeout period in seconds
   $inactive = 600;
    // check to see if $_SESSION['timeout'] is set
   
      if(isset($_SESSION['timeout']) ) {
   
      $session_life = time() - $_SESSION['timeout'];
   
      if($session_life > $inactive)
  
      { session_destroy(); header("Location: logoutpage.php"); }
  
      }
  
      $_SESSION['timeout'] = time();

?>


<table align="center">
<tr>
<td align="center">
<br />

<b>
<a href="main_login.php">Back To Login</a>
</b>
</td>
</tr>
</table>

can anybody help me please

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.