我创建了一个登录系统,用户通过插入电子邮件和密码可以登录到应用程序。在用户创建了他的个人资料页面并设置了他的时间表之后,下面的代码在屏幕上打印了他的个人资料,没有任何错误。这是打印配置文件页面的代码:
<?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这是一个空页面)。我怎么能解决这个问题,使链接将工作和打印用户的时间表?
你应该编辑链接来重新发送电子邮件
链接指向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))
来检查电子邮件格式或使用REGEX