mercredi 4 mars 2015

php if statement and terms and conditions

When a person log into my website for the first time. He needs to accept my terms before making a post. If he accepts, he will never see the form again. I am trying different approaches, and is this the way, or is there a better approach.


First when he log, i check i the facebook token is set. If it's not he is sendt to the mustlogin.php. If the token is set, he be sent to the next check.



<?php
if($_SESSION['fb_token']) {
include ('functions/loginpermission.php');
} else {
include ('template/mustlogin.php');
}
?>


Loginpermission.php:


First i receive the status for the user. If the user have the status 1. He has already accepted the conditions, and will be able to make a post in the post.php form. If not he will receive the termsform.php



<?php
$q = "SELECT status FROM users where id = $id";
$r = mysqli_query($dbc, $q);

while($vote_list = mysqli_fetch_assoc($r)) { ?>

<?php


if($vote_list[status] = 1){
include ('functions/post.php');
} else {
include ('template/termsform.php');
}
?>
<?php } ?>


It doesnt work and i can't se the error. I suspect the approach to be wrong, but i can find another way. I need some inspiration.


I think the problem is that, the further i go php statements will run inside another php statement and the end there will be a php inside a php and the a form for the post. help me!


Aucun commentaire:

Enregistrer un commentaire