gpt4 book ai didi

php - 我无法提交表格

转载 作者:行者123 更新时间:2023-11-29 13:48:28 25 4
gpt4 key购买 nike

我正在一个培训和安置网站上工作,我遇到了一个小问题,但我被困住了..希望我能得到帮助..登录页面的代码如下...这是tpr.php

<?php require_once("includes/tsession.php");?>
<?php require_once("includes/connection.php");?>
<?php require_once("includes/functions.php");?>
<?php

if (isset($_POST['submit']))
{
$branch = trim(mysql_prep($_POST['branch']));
$tprid = trim(mysql_prep($_POST['tprid']));
$password = trim(mysql_prep($_POST['password']));

$hashed_password = sha1($password);

$query = "SELECT t.userID FROM tpr t,branch b WHERE b.branch_ID=t.branch_id AND b.branch_name='{$branch}'
AND t.password = '{$hashed_password}' AND t.userID='{$tprid}' limit 1" or die(mysql_error());
$result_set = mysql_query($query);
confirm_query($result_set);


if (mysql_num_rows($result_set) == 1 ) {
// username/password authenticated
// and only 1 match

echo "<script type='text/javascript'>alert('Username /password/branch combination correct.');</script>";
$found_user = mysql_fetch_array($result_set);



$_SESSION['sessionid2']=$found_user['Userid'];
redirect_to("tpr.php");
} else {
// username/password combo was not found in the database

echo "<script type='text/javascript'>alert('Username/password/branch combination incorrect.');</script>";
$message = "Username/password/branch combination incorrect.<br />
}
}
else{
if(isset($_GET['logout']) && ($_GET['logout']==1) )
{
$message= "You are now logged out";
}
echo "<script type='text/javascript'>alert('out of submit');</script>";

$tpoid="";
$password="";
}
?>
<?php include("includes/header.php"); ?>
<div id="main">
<table id="structure">
<tr>
<td id="navigation">
<a href="content.php">Return to Home</a>
</td>
<td id="page">
<h2>Login</h2>
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<form action="tpr_login.php" method="post">
<table id="inner" cellpadding="10">
<tr>
<td>Select Branch</td>
<td>

<?php

$con = mysql_connect("localhost","TestUserFirst","TestUserFirst");
$db = mysql_select_db("student",$con);
$get=mysql_query("SELECT branch_name FROM branch ORDER BY branch_ID ASC");
$option = '';
while($row = mysql_fetch_assoc($get))
{
$option .= '<option value = "'.$row['branch_name'].'">'.$row['branch_name'].'</option>';
}
?>
<select name="branch" id="branch">
<?php echo $option; ?>
</select>
</td>
</tr>
<tr>
<td>TPRId</td>
<td><input type=text name="tprid" id="tprid" value=""></td>
</tr><tr>
<td>Password</td>
<td><input type=password name="password" id="password" value=""></td>
</tr><tr>
<td></td>
<td><input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</td>
</tr>
</form>

</table>
</div>
<?php require("includes/footer.php");?>

tsession 包含 session_start() 和 session 信息..

<?php
session_start();
function tpr_logged_in()
{
return isset($_SESSION['sessionid2']);
}

function confirm_tpr_logged_in()
{
if(!tpr_logged_in())
{
redirect_to("tpr_login.php");
}
}
?>

连接包含数据库初始化...问题是每当我输入正确的信息时它都会显示“未提交”警报,如果一个信息错误,那么它会进入提交并返回错误的密码组合...显然.. .有什么问题吗???

最佳答案

<div id="main">
<table id="structure">
<tr>
<td id="navigation"><a href="content.php">Return to Home</a></td>
<td id="page">
<h2>Login</h2>


<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<form action="tpr_login.php" method="post">
<table id="inner" cellpadding="10">
<tr>
<td>Select Branch</td>
<td>

<?php

$con = mysql_connect("localhost","TestUserFirst","TestUserFirst");
$db = mysql_select_db("student",$con);
$get=mysql_query("SELECT branch_name FROM branch ORDER BY branch_ID ASC");
$option = '';
while($row = mysql_fetch_assoc($get))
{
$option .= '<option value = "'.$row['branch_name'].'">'.$row['branch_name'].'</option>';
}
?>
<select name="branch" id="branch">
<?php echo $option; ?>
</select>
</td>
</tr>
<tr>
<td>TPRId</td>
<td><input type=text name="tprid" id="tprid" value=""></td>
</tr><tr>
<td>Password</td>
<td><input type=password name="password" id="password" value=""></td>
</tr><tr>
<td></td>
<td><input type="submit" name="submit" value="Login"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>

结束</form>标签 </table> 之后而不是 </tr> 之后.

我不确定,但你可以尝试一下。如果不检查,就不可能说出实际的问题。

关于php - 我无法提交表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17084103/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com