Jump to content

mcrackin

Members
  • Posts

    14
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Vancouver, BC
  • Age
    28

mcrackin's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I've got rid of the errors and everything is working fine now except the mailing of my password part.
  2. I'm using this tutorial to make a login system for my website. I'm running the page on my localhost but I'm getting errors all over demo.php that say Notice: Undefined index: msg at ..... What does Undefined index mean and how do I fix this? Matt
  3. So I have a basic login/registration form. I have tested the registration form and it works - each time I fill out the form I can see the record added to the users table in the MySQL database. My problem is with the login form because the code I am using isn't recognizing the username and password as if the record doesn't exist (even though it does). Here is the login form code located on index.php: <form name="login" action="login.php" method="post"> Username: <input name="username" type="text" /><br> Password: <input name="password" type="password" /><br> <input type="image" value="submit" src="home_loginbutton.jpg" alt="submit Button" onMouseOver="this.src='home_loginbutton.jpg'"> </form> Here is the code in login.php: <?php session_start(); $username = $_POST['username']; $password = $_POST['password']; //connect to the database here $username = mysql_real_escape_string($username); $query = "SELECT password, salt FROM users WHERE username = '$username';"; $result = mysql_query($query); if(mysql_num_rows($result) < 1) //no such user exists { header('Location: nouser.php'); die(); } $userData = mysql_fetch_array($result, MYSQL_ASSOC); $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) ); if($hash != $userData['password']) //incorrect password { header('Location: wrongpw.php'); die(); } else { validateUser(); //sets the session data for this user } ?> When I try to login, I am always redirected to "nouser.php". No idea why and I'm a big time newbie. Please help!
  4. my login page is located on index.php because I want users to login immediately. if they have already logged in from a previous session or once they login this time, i want it to say welcome "billy". if not I want my login form to appear. im just trying to get the right statement for 'is this user logged in or not'
  5. 1) Yes, yes 2) Notice: Undefined index: valid in C:\wamp\www\lmc\index.php on line 21 line 21 being var_dump
  6. All I want to happen right now is to say, welcome $username or else say not logged in. I'll cry with joy if I can do just that.
  7. Hi everyone, I'm just trying to made a login/registration system for my website. The login and registration portion is very simple and works fine. Now, I am trying to add session_start() to each page so that the user, once logged in, has special features appear (or else something else if not logged in). At the top of a typical page I have the following: <?php session_start(); function isLoggedIn() { if(isset($_SESSION['valid']) && $_SESSION['valid']) return true; return false; } if(isLoggedIn() == true) { $username = $_POST['username']; } else { $username = 'NOT LOGGED IN'; } echo $username ?> my echo statement appears as NOT LOGGED IN, even though I know I am logged in. I believe it has something to with the function portion but I'm not sure what. I'm pretty newbie so any help is appreciated.
  8. Thanks for the help everyone. You can see the menu in action here. The full menu code can be seen here. menu.txt is inserted via php include for each layout.php. The code isn't as refined as it could be, but it does everything I want it to. Using the switch/elseif commands would only reduce the code by 1kb so I'm not too concerned. I'll keep an eye on this thread if anyone want to help me out with refining the code. It's an easy edit now since I have the entire code in menu.txt =)
  9. Ok it's working now with this code. You can see what happens to the exact same code when indextest.php is open, and when something else is open. <?php $menuopen = basename($_SERVER['PHP_SELF']); if($menuopen == 'indextest.php') { $homeimage = '<a href="index.html" border="0"><img src="menu_home_open.jpg"></a>'; } else { $homeimage = '<a class="homeButton" href="index.php">home</a>'; } ?> <html> <head> <link rel="stylesheet" type="text/css" href="lmcstyle.css"> </head> <body> <?php echo $homeimage; ?> </body> </html> But like you guys say, I'll have to redo this code for each menu item (7 times). Can someone work with me with the code in this reply to get the desired effect for all 7 menu items?
  10. Here's my new code. <?php $menuopen = $_SERVER['PHP_SELF']; if ($menuopen = "/indextest.php") { $homeimage = '<a href="index.html" border="0"><img src="menu_home_open.jpg"></a>'; } else { $homeimage = '<a class="homeButton" href="index.php">home</a>'; } ?> <html> <head> <link rel="stylesheet" type="text/css" href="lmcstyle.css"> </head> <body> <?php echo $homeimage; ?> </body> </html> Everything appears to be working except the $_SERVER['PHP_SELF'] part. No matter what the name is of the current file, it still shows the "open" code in the document. You can see this by visiting this link and this link Am I using the wrong code to get the current open file?
  11. To start, its not working. Parse error: syntax error, unexpected T_STRING in /srv/disk2/1429064/www/luptakmcleod.co.nf/indextest.php on line 8 It's probably something to do with all the quotes?
  12. Hi everyone, I'm working on a personal website with a friend from school. You can see it here http://luptakmcleod.co.nf You can see that I've spent considerable time on the main menu. When the current page is open, the menu will show the appropriate image, while all other menu items will show the mouseover effect with the appropriate image. For each page corresponding with each menu item, I've had to create different code for the menu to show the right image when that page is open. Now, I want to use the <?php include> tag for the menu and place the menu in a single file (menu.php) so that when I make changes to the menu, the changes appear on every page. The problem with this is that I need to have a certain image open for each page. Ie. if index.php is currently open, then the menu_home_open.jpg image will appear instead of the hover image. When I am in the aboutus.php file, the menu_about_open.jpg image should appear instead of the hover image. The only way I can think of doing this is by the if...else statements. I am extremely new to php so I have little knowledge on how to do this. I've started with the following: //The ifelse code <?php $menuopen = $_SERVER['PHP_SELF']; if ($menuopen = "index.php") { $homeimage = "<a href="index.php" border="0"><img src="menu_home_open.jpg"></a>"; } else { $homeimage = "<a class="homeButton" href="index.php">home</a>"; } ?> //Place this where I want the code to insert <?php include '$homeimage'; ?> I'm not sure of any of the above and I"m sure there's basic errors. I'm very newbie. But as you can see I basically want a line of code to appear if that page is open, or else the other line of code to appear. Any help is appreciated!
  13. This is the error: Deprecated: Function session_is_registered() is deprecated in login_success.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at login_success.php:3) in login_success.php on line 4 This is the code I am using: <?php session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <body> Login Successful </body> </html>
×
×
  • 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.