这一行:
$newpass = (isset($_POST['newpass'])) ? $_POST['newpass'] : '';
检查是否将调用的变量newpass
发布到脚本中。
选项选择值可以通过 javascript/jQuery 获取并发布到 php 脚本(服务器端),以便通过 AJAX 或 GET/POST 执行操作。这是一个例子:
<html>
<head>
<!--<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>-->
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#mySelect').change(function() {
var sel = $(this).val();
//alert(sel);
$.ajax({
type: "POST",
url: "another_php_file.php",
data: 'theOption=' + sel,
success: function(data) {
}
});
});
});
</script>
</head>
<body>
<select name="students" id="mySelect">
<option value="">Please Select</option>
<option value="john">John Doe</option>
<option value="Mike">Mike Smith</option>
</select>
文件:ANOTHER_PHP_FILE.php
$theVar = $_POST['theOption'];
echo 'I received [' . $theVar . ']';