Right where Register is at i get a parse error. it is suppose to redirect based on if the user typed in the correct username and password by looking through each to compare, to the input page but it wont work! any ideas?
<?php
$conn = odbc_connect('Driver={Microsoft Access Driver (*.mdb, *.accdb)};
DBQ= e:\user\kyle.kinsey\database\Final.accdb','','');
// username and password sent from form, 'Username' is from name below in the html part
$myusername = '';
$mypassword = '';
$myusername = $_POST["Username"];
$mypassword = $_POST["Password"];
$db_name="Final"; // Database name
$tbl_name="Accounts"; // Table name
$sql = "SELECT * FROM $tbl_name WHERE Username = '$myusername' AND Password = '$mypassword'";
// not this, because it is not access, which is what we are using, $result = mysql_query($sql);
//*** we are using access and not mysql ($result = mysql_query($sql);)
// $rs = odbc_exec($conn,$sql); is what is used to connect to a access database i think.
$rs = odbc_exec($conn,$sql);
///****** loop through recordset and count the number of returned records
$count = 0;
while ($row = odbc_fetch_array($rs))
{
$count++;
}
if ($count >0)
{
//**** redirect user
Register $myusername, $mypassword and redirect to file ("Input.php"); // dose it redirect?
session_register("myusername");
session_register("mypassword");
header("location:Input.php");
}
else
{
//***** display error
echo "Sorry, no matches found";
}
odbc_close($conn);
?>
<!DOCTYPE htm1
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>KLK: Final </title>
<script ></script>
<style type="text/css">
body {font-family:Times New Roman; font-size:14pt; color:Silver, background:blue}
h2 {text-align:center}
h2, h3 {color:#2E8B57}
.fnote {font-size:7pt}
div#Offset {text-align:center}
</style>
</head>
<body>
<form name="Login" method="post" action="Login.php">
<div id="Offset">
Login: <input type="text" name="Username" id="Username"><br>
Password: <input type="text" name="Password"><br>
<input type="submit" name="Search" value="Search" id ="Search">
</div>
</form>
</body>
</html>
According to the PHP Documentation, session_register() is deprecated. Instead, you can initialize your session using session_start():
<?php
session_start();
$_SESSION['myusername'] = $myusername;
$_SESSION['mypassword'] = $mypassword;
header('Location: input.php');
?>
Check PHP's documentation on comment syntax
To fix your parse error, prepend // to the line that's throwing the error. So it will become:
//Register $myusername, $mypassword and redirect to file ("Input.php");
If you tried it and still get the error, show us what you've tried.
Would have commented but I don't have rep for that.