0

我创建了一个登录系统,用户可以通过插入电子邮件和密码登录到应用程序。在用户创建他的个人资料页面并设置他的时间表后,以下代码将在屏幕上打印他的个人资料,没有任何错误。这是打印个人资料页面的代码:

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

    $email = $_GET['email'];

  if(user_exists($email) === true) {

        $user_id = user_id_from_email($email);
        $profile_data = user_data($user_id,'name','surname','email');
?>

<h1><font size="5"><?php echo $profile_data['name'];?> <?php echo $profile_data['surname']; ?> </font></h1>

<a href="profile_timetable.php" >Timetable</a>

<?php

}else {
    echo 'Sorry, that user does not exist!';
}
  }else{
     header('Location: index.php');
     exit();
   }

我也有一个 .htaccess 文件,它是这样的:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /work/profile.php?email=$1

这是打印时间表页面的代码:

<?

if(  isset($_GET['email']) === true  &&  empty($_GET['email']) === false  ){


$email = $_GET['email'];

    if(user_exists($email) === true) {

       $user_id = user_id_from_email($email);

       $profile_data_timetable = $user_data_profile_timetable($user_id,'hour_start_1','minute_start_1','hour_finish_1','minute_finish_1','activity_1');

?>

<font size="5"> 
    <?php echo $user_data_profile_timetable['hour_start_1']; ?> 
    <?php echo $user_data_profile_timetable['minute_start_1']; ?> 
    <?php echo $user_data_profile_timetable['hour_finish_1']; ?> 
    <?php echo $user_data_profile_timetable['minute_finish_1']; ?> 
    <?php echo $user_data_profile_timetable['activity_1']; ?> 
</font>

<?php
  }else {
echo 'Sorry, that user does not exist!';
}
 }else{
header('Location: index.php');
exit();
 }

我的问题是,如果我单击“时间表链接”来获取用户的时间表,我只会得到一个空屏幕(可能会重定向到 index.php,这是一个空页面)。我该如何解决这个问题,以便链接能够正常工作并打印用户的时间表?

4

1 回答 1

1

哟应该编辑链接重新发送电子邮件

链接会去,profile_timetable.php但它应该去profile_timetable.php?email=fooo@foo.fo

你可以试试这个:

<a href="profile_timetable.php?email=<?php echo $email; ?>" >Timetable</a>

我注意到您没有检查提交的电子邮件是否具有有效格式,请小心注入!

您可以简单地使用if(filter_var($email, FILTER_VALIDATE_EMAIL))检查电子邮件格式或使用正则表达式

于 2013-03-12T15:15:29.760 回答