dourang6423 2015-05-23 15:42
浏览 19
已采纳

如何更改$ _GET ['phone']; 在$ _GET ['url'];? [关闭]

How can I change $_GET['phone']; on $_GET['url']; ? I can not change help me please!

At me now this kind of

site.com/profile.php?phone=$1

I need this kind of

site.com/profile.php?url=$1

<?php
if (isset($_GET['phone']) === true && empty($_GET['phone']) === false) {
    $phone = $_GET['phone'];

    if (user_exists($phone) === true) {
        $id      = id_from_phone($phone);
        $profile_data = user_data($id, 'url', 'first_name', 'last_name', 'email');
    }
}
?>

<?php
function user_exists($phone) {
    $phone = sanitize($phone);
    return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `phone` = '$phone'"), 0) == 1) ? true : false;
}

function id_from_phone($phone) {
    $phone = sanitize($phone);
    return mysql_result(mysql_query("SELECT `id` FROM `users` WHERE `phone` = '$phone'"), 0, 'id');
}

function login($phone, $password) {
    $id = id_from_phone($phone);

    $phone = sanitize($phone);
    $password = md5($password);

    return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `users` WHERE `phone` = '$phone' AND `password` = '$password'"), 0) == 1) ? $id : false;
}
?>

UPDATE

I found other topographical error. I can not ask a question. Please help me what to do ?!

  • 写回答

1条回答 默认 最新

  • dongshao6591 2015-05-23 16:03
    关注

    Every link that has this:

    site.com/profile.php?phone=$1
    

    change to this:

    site.com/profile.php?url=$1
    

    Then in this section:

    <?php
    if (isset($_GET['url']) === true && empty($_GET['url']) === false) {
    $phone = $_GET['url'];
    
    if (user_exists($phone) === true) {
        $id      = id_from_phone($phone);
        $profile_data = user_data($id, 'url', 'first_name', 'last_name', 'email');
    }
    }
    ?>
    

    You can leave the rest as it is, or go and change every $phone to $url, but you will nee to change :

    $phone = $_GET['url'];
    

    to

    $url = $_GET['url'];
    

    After this just simple find all the link to profile.php and change the last bit from phone to url.

    Also, as others have pointed out, its worth looking into changing your mysql_ to either mysqli or PDO

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题