Jump to content

JeffC

Members
  • Posts

    6
  • Joined

  • Last visited

About JeffC

  • Birthday 08/19/1997

Previous Fields

  • Languages
    HTML, CSS

Profile Information

  • Location
    Braintree, MA

JeffC's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. So what I should do, is switch $query, with $_data, and then, after$_data = "SELECT * FROM shared";$_data = ['shared'];, I need to add $_data = array('shared' => array()); below this?
  2. Hi,I have finished making the multiple user account interface, but, now I am having trouble with another feature of the interface.The purpose of the code that I have added, is to reference the "shared" table of the database. But when I try to call a cell from the table farther below, I get the following error:Notice: Undefined index: shared in [filepath] on line 134. What I am currently trying to do to call the second table and then store it as a variable, is this: $query = " SELECT * FROM shared ";$_data = ['shared']; The error on line 134 is caused by the following code: <?php echo htmlentities($_data['shared']['variable'], ENT_QUOTES, 'UTF-8'); ?> The full relevant code is below. <!doctype html><?php require("common.php"); $submitted_username = '';$query = " SELECT * FROM shared ";$_data = ['shared']; if(!empty($_POST)) { $query = " SELECT id, username, password, salt, email, firstname, lastname, accountType FROM users WHERE username = :username "; $query_params = array( ':username' => $_POST['username'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { . die("Failed to run query: " . $ex->getMessage()); } $login_ok = false; $row = $stmt->fetch(); if($row) { $check_password = hash('sha256', $_POST['password'] . $row['salt']); for($round = 0; $round < 65536; $round++) { $check_password = hash('sha256', $check_password . $row['salt']); } if($check_password === $row['password']) { $login_ok = true; } } if($login_ok) { unset($row['salt']); unset($row['password']); $_SESSION['user'] = $row; header("Location: private.php"); die("Redirecting to: private.php"); } else { print("Login Failed."); $submitted_username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'); } } ?><body data-accent="blue"> <!-- Prompt IE 6 users to install Chrome Frame. Remove this if you support IE 6. chromium.org/developers/how-tos/chrome-frame-getting-started --> <!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]--> <header id="nav-bar" class="container-fluid"> <div class="row-fluid"> <div class="span8"> <div id="header-container"> <div class="dropdown"> <a class="header-dropdown dropdown-toggle accent-color" data-toggle="dropdown" href="#"> Cloud<?php echo htmlentities($_data['shared']['variable'], ENT_QUOTES, 'UTF-8'); ?> </a> </div> </div> </div> </div> </header> <div class="container-fluid"> <div class="row-fluid"> <div style="text-align: center;" class="metro span12"> <p>Woah there champ! Before you move any further, you need to be logged in!</p> <form action="login.php" method="post"> Username:<br /> <input type="text" name="username" value="<?php echo $submitted_username; ?>" /> <br /><br /> Password:<br /> <input type="password" name="password" value="" /> <br /><br /> <input type="submit" class="btn btn-primary" value="Log Me In!"> </form> If someone could help that would be great!
  3. Hi,I am currently trying to develop a login system for my website, that involves user accounts that have different privilege levels.I have two different pages involved with logging users in.This first page is a simple page that just executes the common.php file, and then redirects the user to a different page depending on whether or not they are logged in. <?php require("common.php"); if(empty($_SESSION['user'])) { header("Location: login.php"); die("Redirecting to login.php"); }else{ header("Location: redirect.php"); die("Redirecting to redirect.php");}?> The following code is the php part of the logon interface. <?php require("common.php"); $submitted_username = ''; if(!empty($_POST)) { $query = " SELECT id, username, password, salt, email, firstname, lastname, accountType FROM users WHERE username = :username "; $query_params = array( ':username' => $_POST['username'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $login_ok = false; $row = $stmt->fetch(); if($row) { $check_password = hash('sha256', $_POST['password'] . $row['salt']); for($round = 0; $round < 65536; $round++) { $check_password = hash('sha256', $check_password . $row['salt']); } { $login_ok = true; } } if($login_ok) { unset($row['salt']); unset($row['password']); $_SESSION['user'] = $row; header("Location: private.php"); die("Redirecting to: private.php"); } else { print("Login Failed."); $submitted_username = htmlentities($_POST['username'], ENT_QUOTES, 'UTF-8'); } } ?> The purpose of the redirect.php page referenced in the first piece of code is to determine what account level your account is, and then redirect you to the appropriate page.The user's account type is stored in the "accountType" cell in the mySQL table.What I don't know how to do, is have the redirect.php file look in a specific cell (the accountType cell), and redirect accordingly. All I can think of right now would be this: <?php require("common.php"); if(//The statement would probably go here!{ header("location: admin.php"); die("Redirecting To: admin.php");}else if(//another statement{ header("location: whatever.php"); die("Redirecting To: whatever.php");}else{ header("location: whatever.php"); die("Redirecting To: whatever.php");}?> Would the if statement for the first part of the if statement (redirecting to admin.php) be something like "if($_SESSION['accountType'] = ['admin'])"?
  4. It isn't that I am checking for errors, it is that there is a piece of it that does not work for some reason, that no matter what I try, I simply cannot fix it.
  5. Hello,I am trying to make a menu, with bars that slide out from the side to connect to other menu bars. The issue I have is when I put the mouse over the "Home" button, the bar does not slide out from the side. The code is below. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head> <title>Untitled</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><link rel=stylesheet href="style.css" style="text/css" media="screen"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script src="cufon.js" type="text/javascript"></script><script src="jquery.easing.1.3.js" type="text/javascript"></script><script type="text/javascript"> $(function() { Cufon.replace('a, span').CSS.ready(function() { var $menu = $("#slidingMenu"); var $selected = $menu.find('#active'); var $moving = $('<li />',{ className : 'move', top : $selected[0].offsetTop + 'px', width : $selected[0].offsetWidth + 'px' }); $moving.css('top',$selected[0].offsetTop + 'px'); $('#slidingMenuDesc > div').each(function(i){ var $this = $(this); $this.css('top',$menu.find('li:nth-child('+parseInt(i+2)+')')[0].offsetTop + 'px'); }); $menu.bind('mouseleave',function(){ moveTo($selected,400); }) .append($moving) .find('li') .not('.move') .bind('mouseenter',function(){ var $this = $(this); var offsetLeft = $this.offset().left - 20; $('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':offsetLeft+'px'},400, 'easeOutExpo'); moveTo($this,400); }) .bind('mouseleave',function(){ var $this = $(this); var offsetLeft = $this.offset().left - 20; $('#slidingMenuDesc > div:nth-child('+ parseInt($this.index()) +')').stop(true).animate({'width':'0px'},400, 'easeOutExpo'); });; function moveTo($elem,speed){ $moving.stop(true).animate({ top : $elem[0].offsetTop + 'px', width : $elem[0].offsetWidth + 'px' }, speed, 'easeOutExpo'); } }) ; }); </script></head><body> <div id="menu"> <div id="slidingMenuDesc" class="slidingMenuDesc"> <div><span></span></div> <div><span></span></div> <div><span></span></div> <div><span></span></div> <div><span></span></div> </div> <ul id ="slidingMenu" class="slidingMenu"> <li id="active"><a href="#">Home</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Services</a></li> <li><a href="#">News</a></li> <li><a href="#">About Us</a></li> <li><a href="#">Contact Us</a></li> </ul> </div> <div id="Welcome"> <h1>Welcome.</h1> <p></p> </div></body></html> There are four files attached, which contain the code for the whole website. If someone could take a look and tell me what is wrong, I would appreciate it. JQuery menu.zip
×
×
  • Create New...