一个提交表单的重定向问题

good__girl 2004-12-06 06:10:36
我这个文件验证成功想提交到echo "<script>window.location='reg.php?username="&$_POST['username']&"password="&$_POST['password']&"';</script>";这个页面,这段代码怎么提交不过去,还是当前页面?
<?php
session_start();
if (!empty($_SESSION['num']) and !empty($_SESSION['num']) and $_SESSION['num']==$_POST['number']){//验证
echo "<script>alert('成功');windows.close();</script>";
echo "<script>window.location='reg.php?username="&$_POST['username']&"password="&$_POST['password']&"';</script>";
}else{
echo "失败";
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<table width="255" border="0" align="center" cellpadding="6">
<tr>
<td>用户名: </td>
<td><input name="username" type="text" size="15" /></td>
<td> </td>
</tr>
<tr>
<td>密 码:</td>
<td><input name="password" type="text" size="15" /></td>
<td> </td>
</tr>
<tr>
<td>验证码:</td>
<td><input name="number" type="text" size="15" /></td>
<td><img src="image.php" alt="验证图" /></td>
</tr>
<tr align="center">
<td colspan="3"> <input type="submit" name="submit" value="提交" /> 
<input type="submit" name="submit" value="取消" /></td></tr>
</table>
</form>
...全文
332 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fzjw 2004-12-07
  • 打赏
  • 举报
回复
<?php
session_start();

if (!empty($_SESSION['num']) and $_SESSION['num']==$_POST['number']) {
$goto ="reg.php?username=".$_POST['username']."&password=".$_POST['password'];
Header("location: $goto);
} else {
exit("失败");
}
?>
朝阳 2004-12-06
  • 打赏
  • 举报
回复
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
如果你要把值提交到reg.php页,可以将上面的代码改为
<form method="post" action="reg.php?act=1">
在reg.php中用
<?php
if($_GET[act]=='1')
{
程序处理
}
?>
good__girl 2004-12-06
  • 打赏
  • 举报
回复
可以吧
good__girl 2004-12-06
  • 打赏
  • 举报
回复
什么方法都行,只要能实现 验证失败提示重新输入,验证成功转到reg.php这个文件就可以
daikaiming 2004-12-06
  • 打赏
  • 举报
回复
<SCRIPT>里面可以直接调用PHP变量吗??

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧