zero_ZX Posted June 3, 2008 Share Posted June 3, 2008 Hi there. I'm in a big trouble. i've searched at google and aswell as this site (it gaves 40 pages, and after checking 5 i deicded to open a topic) I'm sure it has been asked for but any ways: I'm very new at php and im trying to learn. Right now i've downloaded and edited a nice little login script, and i've already edit it alot. Now what i need is to make the page display "you are now logged in as %username%". Can any one help me at that one? Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/ Share on other sites More sharing options...
freeloader Posted June 3, 2008 Share Posted June 3, 2008 What's the part that checks your login data? We need to know what the session variable is registered as before we can output it. Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556515 Share on other sites More sharing options...
jonsjava Posted June 3, 2008 Share Posted June 3, 2008 More than willing to help. Just as soon as you post your code. Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556517 Share on other sites More sharing options...
kev wood Posted June 3, 2008 Share Posted June 3, 2008 if you are moving to a new page were you want this to be displayed then you would have to use something like You are now logged in as <?php echo $_POST["username"]; ?> depending on how you are posting your information across from the login page. it would be nice to see that code Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556521 Share on other sites More sharing options...
zero_ZX Posted June 3, 2008 Author Share Posted June 3, 2008 My login page/code (there are also some html, i hope it doesnt annoy you too much) <?php require_once('Connections/modulatemedia.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=md5($_POST['password']); $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "admin.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_modulatemedia, $modulatemedia); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $modulatemedia) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <style type="text/css"> body { background-color: #000000; background-image: url(nsa.jpg); background-repeat: no-repeat; } #container { background-image:url(nsa.jpg); margin-left:auto; margin-right:auto; height: 400px; width: 500px; text-align:center; } .style1 { color: #663300; font-family: Arial, Helvetica, sans-serif; font-weight: bold; } .style3 {color: #330000} .style5 { color: #000000; font-family: Arial, Helvetica, sans-serif; font-weight: bold; } </style></head> <script type="text/javascript"> <!-- function MM_validateForm() { //v4.0 if (document.getElementById){ var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments; for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]); if (val) { nm=val.name; if ((val=val.value)!="") { if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@'); if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n'; } else if (test!='R') { num = parseFloat(val); if (isNaN(val)) errors+='- '+nm+' must contain a number.\n'; if (test.indexOf('inRange') != -1) { p=test.indexOf(':'); min=test.substring(8,p); max=test.substring(p+1); if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n'; } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; } } if (errors) alert('The following error(s) occurred:\n'+errors); document.MM_returnValue = (errors == ''); } } //--> </script> <form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST"> <label></label> </span> <div align="right" class="style3"> <div align="left"><strong>Username:</strong></div> </div> </td> <td width="152"><input name="username" type="text" id="username" tabindex="1" maxlength="20" /></td> </tr> <tr> </span> <div align="right" class="style3"> <div align="left"><strong>Password:</strong></div> </div> </td> <td><input name="password" type="password" id="password" tabindex="2" maxlength="20" /></td> </tr> <tr> <td> </td> <td><input name="submit" type="submit" id="submit" tabindex="4" onclick="MM_validateForm('username','','R');MM_validateForm('password','','R');MM_validateForm('email','','RisEmail');return document.MM_returnValue" value="Login" /></td> </tr> <tr> </tr> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556532 Share on other sites More sharing options...
runnerjp Posted June 3, 2008 Share Posted June 3, 2008 if you are moving to a new page were you want this to be displayed then you would have to use something like You are now logged in as <?php echo $_POST["username"]; ?> depending on how you are posting your information across from the login page. it would be nice to see that code ^^^ do that ^^^^ Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556534 Share on other sites More sharing options...
freeloader Posted June 3, 2008 Share Posted June 3, 2008 You are now logged in as <?php echo $_SESSION['MM_Username']; ?> Should do the trick. Using POST will only work on the first page... Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556538 Share on other sites More sharing options...
zero_ZX Posted June 3, 2008 Author Share Posted June 3, 2008 Oh my god guys, thats so nice, ill try to figure out how to post the MD5 Access hash now. (if any one wants to help please pm, since i will mark this topic as solved for now) Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556544 Share on other sites More sharing options...
freeloader Posted June 3, 2008 Share Posted June 3, 2008 //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; Find that and add: $_SESSION['MM_Password'] = $password; On every page, the md5 psw hash will be stored as $_SESSION['MM_Password'] Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556563 Share on other sites More sharing options...
zero_ZX Posted June 3, 2008 Author Share Posted June 3, 2008 OMG thats totally nice, thank you very much! Link to comment https://forums.phpfreaks.com/topic/108533-solved-logged-in-as/#findComment-556566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.