dongqian3198 2015-03-25 09:19
浏览 49
已采纳

数组在打印时显示,但无法与php中的字符串进行比较

I am trying to write a php script to confirm an email address. I am using a file instead of a database to store user info which is outside the root directory. The file is csv.

When I try to store its contents in an array and print it, it works but when I try to compare an element from the array, it doesn't work. And also I want to write the email address of the user in csv as the last entry on the same line as other info.

Please help.

<?php
    $rows[] = array();
    $username = $_GET["username"];
    $passkey = $_GET["passkey"];
    $userdata = fopen("/****/*********/*****/$username.csv", "r");
    $email = $_GET["email"];
    $line = file_get_contents("/****/********/*****/$username.csv");
    $rows = explode(",", $line);

    print_r ($rows);
    $newrows = trim($rows[6]);
    $newpasskey = trim($passkey);

    if($newrows == $newpasskey)
    {
        echo "Email-Id confirmed.";
        fclose($userdata);
        $userdata = fopen("/****/********/******/$username.csv", "a+");
        fwrite($userdata, ",".$email);
        fclose($userdata);
    }
?>
  • 写回答

3条回答 默认 最新

  • douyan8266 2015-03-25 10:20
    关注

    I found out the reason.I had made a mistake while entering the user info onto the file. I changed the php script that enters user info to the file. Now it works perfectly.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度