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 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题