PHP - Adding Diffrent Uer Levels To A Page
I just added a user log on for a site I am building using PHP. I used a simple session based system for this. I can log on just fine. What I am looking for is a way to pass on in ht session what rank a user is so some links/pages will only show for the admin or the super user but not the normal user. I rank the users as Admin 1, superuser 2, and user 3.
This is what I have for the session in my header that allows you to be logged in. Code: [Select] <? session_start(); if(!session_is_registered(myusername)){ header("location:login.php"); } ?> Here is what I have that starts the session Code: [Select] //Connection stuff $query="SELECT * FROM user WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($query); $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:index.php"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Similar TutorialsI need my select dropdown to show the relevant option. I am using a GET action to pass the id of an article to another page (edit article page) with this i am selecting that specific record and passing it's data into form object in order to be modified and updated. The only issue is my category list is a dropdown and i need it to display the relivent category for that specific record. hope that makes sence This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=350052.0 Hello, im looking for some help if anyone can be of help... i want to read from a file each line of that file, for each line search the database for that line found in the file and return what comes back, but i want it todo this for the whole file which could be up to 500 diffrent lines. what i have so far doesnt work ive tried a number of things including foreach() some of this could i got some somewhere else they said it worked for them. $lines = file("/var/www/htdocs/mp32/playlist.lst"); require('dbconfig1.php');//connect to db script while($n < count($lines)) { //get number of lines in file or array $recipeQuery = mysqli_query($conn1, "SELECT * FROM mp_id3_tags WHERE filename LIKE = '$lines[$n]'"); //query database for each one while($recipeQuery1 = mysqli_fetch_array($recipeQuery)) { print "{$recipeQuery1['artist']}"; } $n = $n + 1; } ok im trying to create a admin panel but i want to be able to set what level of power they have how would i start i know that i have to use a enum Hi, I am a php newbie, who has a page that relies on some php scripts, and to which I am trying to add a login page written in php. I took the example from he http://www.howtodothings.com/computers-internet/how-to-make-a-login-system-for-your-website Basically it consists of adding: <? require("log.php"); ?> to the top of any page I want to protect, a log.php file which performs the actions of the form, linking to a mySQL database, and a login.php file which contains the form. I have the login working fine, but it breaks one of the PHP scripts on the page that is protected. It is an upload script, called Weaverbox, based on FancyUpload. The uploads which are handled by a file called upload.php, aren't happening. The progress shows that they are being uploaded, but nothing is uploaded, and there is no success message. As soon as I remove the code from the top of the page requiring log.php all works fine again. I think I may have to add some rules/extensions to resolve this conflict, but I don't know how to go about this. Would someone be able to help me get it sorted? Thanks Nick Happy Monday All! I am writing some code to try to pull in some XML from the TVA on lake levels. This file is updated about every 3 to 4 hours. I have the startings to pull the data in, but running into some problems. Here is a break down of the problems. I am fairly new to PHP, but trying to learn as I go. Any help would be greatly appreciated. The code I have will not pull in the data and display One I am able to display the code, I need to review the upsteam elevation and compare to the previous levels and show the lake rising, falling, or stable. Here is my code: Code: [Select] <?php $html = file_get_contents('http://www.tva.gov/lakes/xml/OHH_R.xml'); $xml = simplexml_load_file('$html'); echo $html->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } ?> I am fairly new to PHP, but trying to learn as I go. Any help would be greatly appreciated. i know how to get my current directory, and the root path, but what i'm needing to do is find the levels of the current dir, for instance, if i'm in: domain.com/folder1 or if i'm in domain.com/folder1/folder2 or if i'm in domain.com/folder1/folder2/folder3 can someone help? thanks much GN I am working on this page concept of pedigree. How can I foreach or create a loop that can get 6 levels of parents, for example name= 1 ; nfather=2; nmohter = 3 and the loop continue to get or consider nfather as a name = 2 and get his parents. this is my table any help plees
CREATE TABLE horsetest01 (
CREATE INDEX horsetest01_index02
Hi everyone ! I am stuck on a task which I'm sure has been achieved by several others in the past. I need to create a category table with unlimited / infinite levels (depths) of categories, sub-categories, sub-sub-categories, sub-sub-sub-categories and so on. I need to know how to show the category tree through PHP. An example would be great or even a link to another page where someone has laid out a step-by-step tutorial. Please help! Thank you very much! Kind Regards, Xeirus. good evening folks, i have a question regarding the foreach syntax when needing to access something say 3 levels deep into the json architecture here's the example I'm trying to accomplish but when echoing it's not returning the value i need from 3 levels deep. I believe i just don't understand the correct syntax so here's the example any help would he sincerely appreciated.
https://pastebin.com/mEBiMUW5 Hi all, I have a long script that processes only one image at the moment. What I am trying to do is put all the script in to a 'foreach' section so that I can process more than just one image. Could someone show me how to do this, putting all the uploaded images in to an array (i guess is the best option) and tell me what the form input names need to be below. The script I was trying to make in principle was: <?php $reg = "G-BAAA"; $count-number-of-files-being-uploaded = x ; // NUMBER OF FILES?? $number = 0; foreach $_FILES { // THIS IS WHERE THE IMAGES ARE UPLOADED AND THUMBNAILS CREATED. THE NAMES OF THE FILES ARE $reg.$number."."$ext; $number++; } ?> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input type="file" name="image[]" ></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> Hi everyone, The website I am working on is http://teemagroup.com/puyafolder and I have a global navigation with a drop down menu. What I want to do is on the right side have a PHP code to pull sub-pages under the drop down menu that its in. I don't quite know how to write it. For example everything under "Client Services" would go on the right side of that page. You know, to make it locally available instead of a drop down. And this code would work with all other pages. It would just pull what's under that page. I've added some files for you if you need it. This is done in wordpress if you wanted to know. Hi everybody. I am new to PHP and trying to alter a wordpress site. I am using a plugin called backend restrictor and it is a blanket restrictor of all backend functions except profile. I want to add some more urls other than the profile.php page to be allowed but I can't get it right. Can anybody assist? Code: [Select] add_action('admin_init', 'bur_plugin_enforceRestriction'); function bur_plugin_enforceRestriction() { global $current_user; if (current_user_can('manage_options')) { } else{ $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80"): $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; else: $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; endif; // allowed path(s) if ($pageURL == get_bloginfo('wpurl')."/wp-admin/profile.php"){ }else{ header("Location:".get_bloginfo('url')."/"); } } } ?> I have an 'I agree' button on this page https://www.setstuffrentals.com/credit-card-authorization/
I basically need the button to redirect to another web page after a customer hits 'I agree'. I don't know PHP much. Can someone help step by step, please? Hi All. I have been really struggling with this for a while! When a URL loads I wish to load with parameters entered & those parameters entered on a page but cannot get my head round it. Any help will be much appretiated... So when a user navigates to www.test.com/page.php I wish to to actually pull back www.test.com/page.php?term=&submit=Go Any help will be really really appretiated. I am looking to add a comment area to pages that are created with data that is pulled off of a database. I am looking for something like the forums on this site, but not as complex. I was thinking about attempting to use a text file to hold the comments for each ID number that is in my database and then displaying those comments when the ID number is called. I'm not sure how I would go about making a function that would search if there was a text file for that ID number and if not to create one. I'm not even sure if this is the best way to go about it but I know if I put all the comments into a database it will get rather large rather quickly. Any pointers and good tutorials would be welcome. Sorry if it sounds as if this post is rambling, I think I need to step away from the computer for a bit. Thanks Hi iam currently writing some code for my website and i have a number of records that i simply want to display in a table format, i have done this in a while loop and it works well, however i only want to display a maximum of 10 records per page as my div needs to be a fixed height and was wondering how i could include a next button that would act as like a page number. The thing is at any given point there could be from 1 record to display to 500, so i need a way of allowing the user to quickly navigate to the other records. How can i do this without using mulitple pages. Hope this makes sense. Heres my code Code: [Select] <?php echo"<table width='100%' border='1' align='center'><tr><th>Referal Name</th><th>Amount Received</tr>"; while ($row = mysql_fetch_array($sql_info)) { extract($row); echo "<tr><td align='center'>".$username."</td><td align='center'>".$cumulative_referral."</td></tr>"; } echo "</table>"; ?> Thanks for your help When having different levels of directories, using relative paths will not work anymore, for example: controller - authentication File 1: include('../../model/header.php') model File 2: header.php view File 3. style.css The header.php file includes the css file with a relative path, but the problem is it includes it as follows: ../view/style.css When now the header.php file gets included into File 1 in the folder "authentication", then the css file will not be accessible anymore, for it to be accessible you would have to go two directories up. In this sense my question is, what would be the proper path structure for a folder structure with multiple levels? Should I rather use absolute paths, I am not so prone of absolute path. What if the folders changes a bit, or the domain changes, or the location changes? hope someone can help me out here, stuck on this page... This page shows the details of the listing they had just clicked on on the previous page. this part works If the person logged in is the person who is looking at the page, the email section does not show. this part works However, the part I cannot get to work, is when the logged in user types their email message and clicks send email. at this point the details of listing stop showing please SOMEONE HELP ME thanks in advance, i hope Code: [Select] <?php // Start the session require_once('startsession.php'); // Insert the page header $page_title = 'Listing Details'; require_once('header.php'); require_once('connectvars.php'); // Show the navigation menu require_once('navmenu.php'); if(isset($_POST['submit'])){ $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the user data from MySQL $query1 = 'SELECT email FROM ob_user WHERE username="' . $user_name . '"'; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_fetch_array($data1); $email = $row1['email']; $to = $email; $subject = 'OurBazzar response to' . $subject . ''; $body = $_POST['email']; $headers = 'From: caleb.jordan.flax@gmail.com'; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent!</p>"); } else { echo("<p>Message delivery failed...</p>"); } end(); } if (isset($_GET['listing_id']) && isset($_GET['subject']) && isset($_GET['description']) && isset($_GET['price']) && isset($_GET['date']) && isset($_GET['city']) && isset($_GET['state']) && isset($_GET['user_id']) && isset($_GET['category_id'])) { // Grab the score data from the GET $listing_id = $_GET['listing_id']; $title = $_GET['subject']; $description = $_GET['description']; $price = $_GET['price']; $date = $_GET['date']; $city = $_GET['city']; $state = $_GET['state']; $userid = $_GET['user_id']; $categoryid = $_GET['category_id']; } // Connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); // Retrieve the user data from MySQL $query = 'SELECT username FROM ob_user WHERE user_id="' . $userid . '"'; $data = mysqli_query($dbc, $query); $row = mysqli_fetch_array($data); $query1 = 'SELECT name FROM ob_category WHERE category_id="' . $categoryid . '"'; $data1 = mysqli_query($dbc, $query1); $row1 = mysqli_fetch_array($data1); $user_name = $row['username']; $category_name = $row1['name']; echo '<table>'; echo '<tr><td colspan="2"><strong>' . $title . '</strong></td></tr>'; echo '<tr><td>Created by: </td><td>' . $user_name . '</td></tr>'; echo '<tr><td>Date created: </td><td>' . $date . '</td></tr>'; echo '<tr><td>Location: </td><td>' . $city . ', ' . $state . '</td></tr>'; echo '<tr><td>Category: </td><td>' . $category_name . '</td></tr>'; echo '<tr><td>Description: </td><td>' . $description . '</td></tr>'; echo '</table>'; if ((isset($_SESSION['username'])) && ($_SESSION['username'] != $user_name)) { ?> <br /> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <fieldset> <legend>Send Email to <?php echo $user_name; ?></legend> <label for="email">Message: </label> <input type="text" name="email" /><br /> <input type="submit" value="Send Email" name="submit"> </fieldset> <?php } require_once('footer.php'); ?> Here is my add driver button |