Jump to content
Larry Ullman's Book Forums

Ghamdan

Members
  • Posts

    55
  • Joined

  • Last visited

Ghamdan's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. I am trying to access a variable inside a while loop to echo a message. php passes me an error message saying " undefined var on ..... and ....." How can I implement that when I am using a while loop? Thank you.
  2. 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.
  3. I want to redirect only non-admin users. Admin can access the page only. This is what I am trying to do.
  4. 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.
  5. I have read your post : Enabling Url Rewriting Not Working httpd.conf : LoadModule rewrite_module modules/mod_rewrite.co the htaccess file is: .htaccess But it is still the same. Thank you.
  6. 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.
  7. What I am trying to do is ORDER BY dated_added not views. But the problem is the list is order by active views, means the last post viewed goes first in list which I do not want to. Thank you .
  8. 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'];
  9. // 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.
  10. I want to display some related posts when a post is viewed. For example if the post is about windwos 8 then some related posts to windows 8 will be displayed and so on. This is main idea. How can I implement this feature using php and mysql? Thank you.
×
×
  • Create New...