dqvzfp6468 2012-10-16 18:35
浏览 30
已采纳

验证后将表单变量POST到另一个php文件

<?php
//index.php
session_start(); 
if (isset($_SESSION['username'])) {
header('Location: Pro_Lesson.php');
}
if (isset($_POST['username'], $_POST['password'])){
    if(empty($_POST['username']) || empty( $_POST['password'])){
        echo "username or password are empty";
    }else {
header('Location: login.php');
    }
}
?>
<html>
<head>
</head>
<body>
<h3>User Login</h3>
<table border="0">
<form method="POST" action="index.php">
<tr><td>Username</td><td>:</td><td><input type="text" name="username" size="20"></td></tr>
<tr><td>Password</td><td>:</td><td><input type="password" name="password" size="20"></td></tr>
<tr><td>&nbsp;</td><td>&nbsp;</td><td><input type="submit" value="Login"></td></tr>
</form>
</table>
</body> 
</html>

how can I post the form data to another php page after success validation for username and password ? and is it secure ?

  • 写回答

2条回答 默认 最新

  • doudi7782 2012-10-16 18:40
    关注

    You could do it:

    $_SESSION['posted'] = $_POST;
    

    In other php page:

    print_r($_SESSION['posted']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?