我有这个代码,他们应该传递vercode的值,但不幸的是它没有这样做......我希望它将代码从文本框传递到javascript和php
这是代码:
HTML:
<?php
session_start();
?>
<html>
<title>Adviser Registration</title>
<head>
<link rel="shortcut icon" href="favicon.ico" type="image/ico" />
<script type="text/javascript">
function upperCase()
{
//get ids
var lname=document.getElementById("lname");
var fname=document.getElementById("fname");
var mname=document.getElementById("mname");
//function
lname.value=lname.value.toUpperCase();
fname.value=fname.value.toUpperCase();
mname.value=mname.value.toUpperCase();
}
</script>
<script language="JavaScript" src="js/gen_validatorv31.js" type="text/javascript"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/reg.css">
</head>
<body>
<div id="wrapheader">
</div>
<div id="wrap">
<table width="902" class="tableaccountinfo2" style="border-collapse:collapse; background:url(images/dock-bg.gif)">
<tr>
<td width="39" class="picaccount2"></td>
<td width="851" height="33">Account Info</td>
</tr>
</table>
<table width="898">
<tr>
<td width="30"></td>
<td width="856" style="color:#060; font-size:12px;"><b>*Note:</b>Please make sure that your account information is a registered email address. This will be used as your Autumn Account and for account validation. </td>
</tr>
</table>
<table width="928" align="center" id="tablereg" style="border-collapse:collapse; font-size:14px;">
<tr>
<td height="23"> </td>
</tr>
<tr>
<td width="137" height="44">E-mail Address:</td>
<td width="242"><input type="text" id="email" /></td>
<td width="505"><span id="email_feedback"> </span></td>
</tr>
<tr>
<td height="44">Password:</td>
<td><input type="password" id="pass" /></td>
</tr>
<tr>
<td height="44">Repeat Password:</td>
<td><input type="password" id="rpass" /></td>
<td><span id="pass_av"> </span></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<table id="tablereg" style="width:400px;border-collapse:collapse;font-size:14px;">
<tr>
<td> </td>
</tr>
<tr>
<td width="137">Verification Code: </td>
<td>
<input type="password" id="vercode" name="vercode" />
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!----------------------Personal Info------------------------>
<table width="902" class="tableaccountinfo" style="border-collapse:collapse; background:url(images/dock-bg.gif)" >
<tr>
<td width="36" class="picpersonal"></td>
<td width="854" height="33">
Personal Information
</td>
</tr>
</table>
<table width="899" align="center" id="tablereg" style="border-collapse:collapse;">
<tr>
<td height="23"> </td>
</tr>
<tr>
<td width="123" height="44">Firstname:</td>
<td width="765"><input type="text" id="fname" onChange="upperCase()" /></td>
</tr>
<tr>
<td height="44">Middle Name:</td>
<td><input type="text" id="mname" onChange="upperCase()" /></td>
</tr>
<tr>
<td height="44">Lastname:</td>
<td><input type="text" id="lname" onChange="upperCase()" /></td>
</tr>
<tr>
<td> </td>
</tr>
</table>
<!----------------------School Info------------------------>
<table width="902" class="tableaccountinfo" style="border-collapse:collapse; background:url(images/dock-bg.gif)">
<tr>
<td width="37" class="picstudentinfo"> </td>
<td width="853" height="33">
School Information
</td>
</tr>
</table>
<table style="border-collapse:collapse;" align="center" id="tablereg">
<tr>
<td height="23" width="125px"> </td>
</tr>
<tr>
<td height="44" width="125px">Staff ID:</td>
<td><input type="text" id="staffid" /></td>
</tr>
<tr>
<td height="44" width="125px">College:</td>
<td>
<select id="college">
<option value="please_select">Select your college...</option>
<?php
include "connection.php";
$getcollege = mysql_query("SELECT * FROM college");
while($collrow = mysql_fetch_assoc($getcollege))
{
$coll = $collrow['collegeab'];
$collid = $collrow['college_id'];
?>
<option value="<?php echo $collid; ?>"><?php echo $coll; ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td height="44" width="125px">Coordinator:</td>
<td id="coorhold"> </td>
</tr>
<tr>
<td height="23" width="125px"> </td>
</tr>
</table>
<!----------------------Incase you forgot your password------------------------>
<table width="902" class="tableaccountinfo" style="border-collapse:collapse; background:url(images/dock-bg.gif)">
<tr>
<td width="37" class="picincase"></td>
<td width="853" height="33">
In case you forgot your password
</td>
</tr>
</table>
<!----------------------Registration Result------------------------>
<table width="928px" id="tablereg" style="border-collapse:collapse;">
<tr>
<td><span id="regresult"> </span></td>
</tr>
</table>
<!----------------------Register Button---------------------->
<table width="928" id="tablereg" style="border-collapse:collapse;">
<tr>
<td width="224"></td>
<td width="664"><input type="button" id="submitregister" value="Register" name="submitregister" /></td>
</tr>
</table>
</div>
<script type="text/javascript" src="js/advreg.js"></script>
<script type="text/javascript" src="js/chooseadv.js"></script>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
</body>
</html>
JAVASCRIPT:
$('#submitregister').click(function() {
//grab values
var vercode = $('#vercode').val();
//show loading text
$('#regresult').text('Loading...');
//perform http request
$.post('validations/vadvreg.php', { vercode: vercode
}, function(data){
$('#regresult').html(data);
});
});
PHP
<?php
include 'connection.php';
session_start();
if(isset($_POST['vercode'])){
$vercode = mysql_real_escape_string(htmlentities($_POST['vercode']));
}else {
echo "<font color='red'>Please fill in ALL fields!</font>1";
}
?>