我有一个简单的表单来获取用户名,并希望实现以下目标:
如何实现这个目标?
代码如下,但不按预期工作:
<?php
session_start();
// 当表单提交时处理表单数据
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if(isset($_POST['submit-button'])) {
$uname=$_POST['username'];
header('Location: success.php');
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>My Form</title>
</head>
<body>
<form id="your_form_id" action="test4.php" method="post">
<p><label>Username</label>
<input id="username" type="text" name="username" value="" autofocus/></p>
<input type="submit" id="submit-button" name="submit" value="Login" />
</form>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
$("#submit-button").on("click", function(e){
document.getElementById("submit-button").disabled = true;
document.getElementById("submit-button").value="Processing, please wait...";
document.getElementById("your_form_id").submit();
});
</script>
</body>
</html> Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号