Ghamdan
Members-
Posts
55 -
Joined
-
Last visited
Ghamdan's Achievements
Newbie (1/14)
1
Reputation
-
function redirct_none_admin($check ='user_id', $page='index.php'){ if(!isset($_SESSION[$check])) { $url = BASE_URL . $page; header("Location: $url"); exit(); } elseif($_SESSION['user_type'] != 'admin') { $url = BASE_URL . $page; header("Location: $url"); exit(); } } ======================================== It is working but I do not know if it is the right way to do it.
-
I am trying to create a script that redirect the none admin users. The code below: session_start(); function redirct_none_admin($check ='user_id', $target='index.php'){ if(!isset($_SESSION[$check])) { $url = BASE_URL . $target; header("Location: $url"); exit(); } } function call: // Redirect non-administrators: redirct_none_admin('user_admin'); I could not redirect the none-admin user. Is there anything wrong with this code? How to fix it? Thank you.
-
I am trying to use mode_rewrite in my project but it is not working. httpd.conf Settings: <Directory "C:/xampp/htdocs/mysite/blog"> AllowOverride All </Directory> .htaccess Settings: <IfModule mod_rewrite.co> RewriteEngine on RewriteBase /mysite/blog/ # For article: RewriteRule ^article/([0-9]+)/?$ article.php?id=$1 </IfModule> How can I fix this problem? Thank you.
-
Thank you. The query for page which lists the posts: $q = "SELECT post_id, views ,author, title, content, DATE_FORMAT(date_added, '%M %d, %Y') AS posted FROM posts ORDER BY date_added DESC "; Single post: // views counter: $q = 'UPDATE posts SET `views` = `views`+1 WHERE post_id='.$_GET['id']; $r = mysqli_query($dbc, $q); $q = 'SELECT views, author, title content, DATE_FORMAT(date_added, "%M %d, %Y") AS posted FROM posts WHERE post_id=' . $_GET['id'];
-
// views counter: $q = 'UPDATE posts SET `views` = `views`+1 WHERE post_id='.$_GET['id']; $r = mysqli_query($dbc, $q); This code works fine and I have noticed that when the page is viewed the order of posts in the main page (view_posts.php) changes according to the last post viewed. Although mysql query sets the order by to date_added DESC. The problem is that the last post viewed or displayed goes first in list. How can I fix this issue ? Thank you.