Jump to content

soupy127

Members
  • Posts

    29
  • Joined

  • Last visited

    Never

Everything posted by soupy127

  1. Thanks alot for all your help again ! I shall try it now !
  2. Hi have 2 queries, hope somebody can help. the first is how do i edit this function so that it works with my phpmyadmin database when it has no username or password? The database is called duffers. Everytime i edit it i get errors. (sorry im just learning php) function setupdb($dbuser,$pw,$dbase) { $this->dbuser=$dbuser; $this->pw=$pw; $this->dbase=$dbase; $this->db = mysql_connect('localhost',$dbuser,$pw); } and the second query is, i have my website set up with sessions, so was wandering how do i display the persons information once he has logged in. I.e i need the query to recognise the username from of the the logged in user and only display his information, here was my attempt. <?php //session start and get variable session_start(); $username = $_SESSION['username']; //connect to database $connect = mysql_connect("localhost","root","") or die ("sorry couldn't connect"); mysql_select_db("duffers") or die("couldnt connect"); $get = mysql_query("SELECT * FROM users WHERE username='$username'"); print username ='username', name = 'name', Email = 'email'; <a href='logout.php'>Logout</a>"; } else die("you must be logged in"); ?> any help would be greatly appreciated!! thanks again
  3. Your a life saver, cant believe how stupid i was haha thanks very much again!!
  4. Hi trying to create an admin script that uses sessions, so that i can call this script so that the pages can only be viewed by admins. Here is my script so far and i keep getting error on line 13 please help im not very good at php. <?php //session start and get variable session_start(); $username = $_SESSION['username']; //connect to database $connect = mysql_connect("localhost","root","") or die ("sorry couldn't connect"); mysql_select_db("duffers") or die("couldnt connect"); $get = mysql_query("SELECT * FROM users WHERE username='$username'") while ($row = mysql_fetch_assoc($get)) { $admin = $row['admin']; } if ($admin==0) die("Your Not an Admin!"); ?> Any help would be greatly appreciated thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.