dt2015 2015-10-07 21:31
浏览 28

为什么我的代码在重定向时给出了解析错误

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>
  • 写回答

2条回答 默认 最新

  • dousi5358 2015-10-07 21:42
    关注

    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');
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集