dqteh7347 2014-05-01 05:26 采纳率: 100%
浏览 9
已采纳

在php中获取变量

I have this code my friend sent me through a tutorial for a project;

<?php include 'includes/menu.php'; ?>
    <h1>Activate your account</h1>
    <?php

    if (isset($_GET['success']) === true && empty ($_GET['success']) === true) {
        ?>
        <h3>Thank you, we've activated your account. You're free to log in!</h3>
        <?php

    } else if (isset ($_GET['email'], $_GET['email_code']) === true) {
        $email      =trim($_GET['email']);
        $email_code =trim($_GET['email_code']); 

        if ($users->email_exists($email) === false) {
            $errors[] = 'Sorry, we couldn\'t find that email address';
        } else if ($users->activate($email, $email_code) === false) {
            $errors[] = 'Sorry, we have failed to activate your account';
        }

        if(empty($errors) === false){

            echo '<p>' . implode('</p><p>', $errors) . '</p>';  

        } else {
            header('Location: activate.php?success');
            exit();
        }

    } else {
        header('Location: index.php');
        exit();
    }
    ?>

Basically it activates your acc based on email and email code obviously, the email is; test@test.com and code is; code_536203131f86d3.07314347 how would i activate. Something like domain.com/activate?code_536203131f86d3.07314347 or?

  • 写回答

1条回答 默认 最新

  • douchao0358 2014-05-01 05:31
    关注

    PHP's $_GET variables are sent through the HTTP request's query string. So, your URL would be something like this:

    domain.com/activate.php?email=test@test.com&email_code=code_536203131f86d3.07314347
    

    Your two variables would then be accessible through the superglobal:

    $_GET['email']
    $_GET['email_code']
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题