我正在尝试以编程方式提交表单,但收到一条错误消息: SCRIPT5007: Unable to get value of the property 'submit': object is null or undefined verify1.php, line 9 character 5
谁能看到我做错了什么?这是代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function submitform()
{
document.getElementById("repeatForm").submit();
}
</script>
</head>
<body>
<?php
require_once('recaptchalib.php');
$privatekey = "6Ld1N9ISAAAAAB_lXt0Es0muh2cfikSgVrUP4ZXh";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
echo '<script language="JavaScript">submitform();</script>';
;
/*echo "<script>window.location.href = 'Information-Request-Voodoo-Websites.php';</script>";*/
} else {
echo "<script>window.location.href = 'Confirm-Information-Request.html';</script>";
// Your code here to handle a successful verification
} ?>
<?php
if (isset($_POST['name2'])) $_SESSION['name2'] =$_POST['name2'];
if (isset($_POST['phone'])) $_SESSION['phone'] =$_POST['phone'];
if (isset($_POST['email'])) $_SESSION['email'] =$_POST['email'];
if (isset($_POST['company'])) $_SESSION['company'] =$_POST['company'];
if (isset($_POST['pages'])) $_SESSION['pages'] =$_POST['pages'];
if (isset($_POST['shopping'])) $_SESSION['shopping'] =$_POST['shopping'];
if (isset($_POST['new'])) $_SESSION['new'] =$_POST['new'];
if (isset($_POST['general'])) $_SESSION['general'] =$_POST['general'];
if (isset($_POST['respond'])) $_SESSION['respond'] =$_POST['respond'];
?>
<form id="repeatForm" action="Information-Request-Voodoo-Websites.php" method="post">
<span name="sprytextfield1">
<label for="name2">Please enter your name:</label>
<input name="name" type="text" class="inputTextBoxFormat" id="name2" value="<?php echo((isset($_POST["name"]))?$_POST["name"]:"") ?>" size="30" />
<span class="textfieldRequiredMsg">A value is required.</span></span>
<p><span id="sprytextfield2">
<label for="phone">Please enter your phone number:</label>
<input name="phone" type="text" class="inputTextBoxFormat" id="phone" value="<?php echo((isset($_POST["phone"]))?$_POST["phone"]:"") ?>" />
<span class="textfieldRequiredMsg">A value is required.</span></span></p>
<p><span id="sprytextfield3">
<label for="email">Please enter your email address:</label>
<input name="email" type="text" class="inputTextBoxFormat" id="email" value="<?php echo((isset($_POST["email"]))?$_POST["email"]:"") ?>" size="40" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p>
<p><span id="sprytextarea1">
<label for="company">Enter a brief description of your company:</label>
<br />
<textarea name="company" cols="65" rows="3" class="inputTextBoxFormat" id="company"><?php echo((isset($_POST["company"]))?$_POST["company"]:"") ?></textarea>
<span class="textareaRequiredMsg">A value is required.</span></span></p>
<p>Anticipated number of pages:<span id="sprytextfield4">
<label for="pages"></label>
<input name="pages" type="text" class="inputTextBoxFormat" id="pages" value="<?php echo((isset($_POST["pages"]))?$_POST["pages"]:"") ?>" size="7" />
<span class="textfieldRequiredMsg">A value is required.</span></span><span id="spryselect1">
<label for="shopping">Shopping cart required?</label>
<select name="shopping" class="inputTextBoxFormat" id="shopping">
<option value="yes">yes</option>
<option value="no">no</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span></p>
<p><span id="spryselect2">
<label for="new">Does this work concern a new or existing web site?</label>
<select name="new" class="inputTextBoxFormat" id="new">
<option value="existing" <?php if (!(strcmp("existing", ((isset($_POST["new"]))?$_POST["new"]:"")))) {echo "selected=\"selected\"";} ?>>existing</option>
<option value="new" <?php if (!(strcmp("new", ((isset($_POST["new"]))?$_POST["new"]:"")))) {echo "selected=\"selected\"";} ?>>new</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span></p>
<p><span id="sprytextarea2">
<label for="general">Add any additiional comments here or ask questions. </label>
<textarea name="general" cols="65" rows="4" class="inputTextBoxFormat" id="general"><?php echo((isset($_POST["general"]))?$_POST["general"]:"") ?></textarea>
</span></p>
<p><span id="spryselect3">
<label for="respond">How would you like us to respond?</label>
<select name="respond" class="inputTextBoxFormat" id="respond">
<option value="email" <?php if (!(strcmp("email", ((isset($_POST["respond"]))?$_POST["respond"]:"")))) {echo "selected=\"selected\"";} ?>>email</option>
<option value="phone" <?php if (!(strcmp("phone", ((isset($_POST["respond"]))?$_POST["respond"]:"")))) {echo "selected=\"selected\"";} ?>>phone</option>
</select>
<input type="submit" name="formSubmit" value="Submit" />
</form>
</body>
</html>