33528
33528

Reputation: 382

php profile with .htaccess

I have created a login system where the user by inserting email and password can login to the application. After the user creating his profile page and sets his timetable the following piece of code prints on screen his profile, without any errors. This is the code that prints the profile page:

<?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();
   }

I am also having a .htaccess file which is this:

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

And this is the code that prints the timetable page:

<?

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();
 }

My problem is that if I click on "timetable link" to get the user's timetable, I get just an empty screen (probably redirects to index.php which is an empty page). How can I fix this so that the link will work and prints the user's timetable?

Upvotes: 0

Views: 79

Answers (1)

Acuao
Acuao

Reputation: 691

Yo should edit the link to resend the email

the link is going to profile_timetable.php but it should go to [email protected]

you can try this:

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

i notice that you don't check if submitted email haves a valid format, be carefull about injections!

you can simply use if(filter_var($email, FILTER_VALIDATE_EMAIL)) to check email format or use a REGEX

Upvotes: 1

Related Questions