Help.... i use dreamweaver and create 3 page.
1. JConnection.php
2. Login.php ( use table login1{uname,upass,matric} )
3. profile.php ( use table profile1{name,course,faculty,matric}
i want to use the session , i mean when the user successfully login the system, the user will view their profile page.
but it is not work. anyone know how 2 some the problwm is !
[php]
Jconnection.php
<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_Jconnection = "localhost";
$database_Jconnection = "sample";
$username_Jconnection = "root";
$password_Jconnection = "";
$Jconnection = mysql_pconnect($hostname_Jconnection, $username_Jconnection, $password_Jconnection) or trigger_error(mysql_error(),E_USER_ERROR);
//mysql_select_db($database_Jconnection)
?>
Login.php
<?php
require_once('Connections/Jconnection.php');
if(isset($_POST['username']))
{
$name = $_POST['username'];
$pass = $_POST['password'];
$query_Recordset1 = "select * from login1 where uname = '$name' and upass='$pass'";
$Recordset1 = mysql_query($query_Recordset1) ;//or die (mysql_error));
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
if($totalRows_Recordset1==1)
{
$_SESSION['matric'] = $row_Recordset1['matric'];
echo $_SESSION['matric'];
echo '<script>window.location.href=\'profile.php\'</script>';
}
}
?>
<!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" />
<title>Login</title>
</head>
<body>
<form id="form1" name="form1" method="POST" action="login.php">
<table width="405" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FF9933">
<tr>
<th width="405" bgcolor="#3366FF" scope="col"><span class="style1"></span></th>
</tr>
<tr>
<td><p> </p>
<table width="286" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="286" scope="col">username
<label>
<input name="username" type="text" id="username" />
<br />
<br />
Password
<input name="password" type="text" id="password" />
<br />
<br />
<input type="submit" name="Submit" value="Submit" />
<input type="submit" name="Submit2" value="Cancel" />
</label></th>
</tr>
</table>
</tr>
<tr>
</tr>
</table>
</form>
</body>
</html>
profile.php
<?php require_once('Connections/Jconnection.php'); ?>
<?php
$colname_Recordset1 = "-1";
if (isset($_SESSION['matric'])) {
$colname_Recordset1 = (get_magic_quotes_gpc()) ? $_SESSION['matric'] : addslashes($_SESSION['matric']);
}
mysql_select_db($database_Jconnection, $Jconnection);
$query_Recordset1 = sprintf("SELECT * FROM profile1 WHERE matric = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Jconnection) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//session_start();
<!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" />
<title>Untitled Document</title>
</head>
<body>
<table width="436" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="436" bgcolor="#3399FF" scope="col"> </th>
</tr>
<tr>
<td bgcolor="#FF9933"><form id="form1" name="form1" method="post" action="">
<p></p>
<table width="374" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<th width="328" height="19" scope="col">Name
<label>
<input name="textfield" type="text" value="<?php echo $row_Recordset1['name']; ?>" />
<br />
<br />
Course
<input name="textfield2" type="text" value="<?php echo $row_Recordset1['course']; ?>" />
<br />
<br />
Faculty
<input name="textfield3" type="text" value="<?php echo $row_Recordset1['faculty']; ?>" />
<br />
<br />
<input type="submit" name="Submit" value=" OK " />
<br />
<br />
<br />
</label></th>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td bgcolor="#3399FF"> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>[/php]
Read the Posting Guidelines before you post any further in this forum!
Especially the part about enclosing code within code or php tags!!
You code is absolutely unreadable and can only be read using an IDE (which I will not)
moderator