我正在尝试使用 POST 方法将值从 javascript 传递给 php,但它不起作用。这是代码:
<head>
<script type="text/javascript">
function Email()
{
var e=prompt("Your Email","");
if(e==null||e=="")
{
alert("You need to enter an email..Try again");
Email();
}
return e;
}
function Code()
{
var f=prompt("Activation code","");
if(f==null||f=="")
{
alert("You need to enter the code..Try again");
Code();
}
return f;
}
</script>
</head>
<body>
<form method="post">
<input type="hidden" id="Email" name="Email" />
<input type="hidden" id="Code" name="Code" />
</form>
<script>
var email=Email();
var code=Code();
document.getElementByID("Email").value=email;
document.getElementByID("Code").value=code;
</script>
<?php
$email=$_POST["Email"];
$code=$_POST["Code"];
echo $email.$code;
?>
</body>
我收到这些错误:
- 注意:未定义索引:电子邮件
- 注意:未定义索引:代码
任何人都请帮我...