Jump to content


Photo

login help


  • Please log in to reply
4 replies to this topic

#1 <? ben >?

<? ben >?
  • Members
  • Pip
  • Newbie
  • 3 posts
  • Locationuk

Posted 03 October 2004 - 04:39 PM

hi i have ths code
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "login.php";
  $MM_redirectLoginFailed = "index.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db($database_localhost, $localhost);
  
  $LoginRS__query=sprintf("SELECT username, password FROM logon WHERE username='%s' AND password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $GLOBALS['MM_Username'] = $loginUsername;
    $GLOBALS['MM_UserGroup'] = $loginStrGroup;	      

    //register the session variables
    session_register("MM_Username");
    session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && true) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
on the index.php
and i have a update.php BUT how do i get the username varibal to carry on on the next page
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
  $updateSQL = sprintf("UPDATE logon SET password=%s, age=%s, email=%s, name=%s, advtar=%s, a=%s WHERE username=%s",
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['age'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['advtar'], "text"),
                       GetSQLValueString($_POST['a'], "text"),
                       GetSQLValueString($_POST['username'], "text"));

  mysql_select_db($database_localhost, $localhost);
  $Result1 = mysql_query($updateSQL, $localhost) or die(mysql_error());

  $updateGoTo = "login.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}

$colname_Recordset1 = "1";
if (isset($_GET['WHAT DO I PUT HERE'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['WHAT DO I PUT HERE'] : addslashes($_GET['WHAT DO I PUT HERE']);
}
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = sprintf("SELECT * FROM logon WHERE username = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>

thats my update Bit but were do i get my verabals to account for the username thanks a lot 4 ur help


plz and help Keep Them alive

#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 03 October 2004 - 04:54 PM

It's against forum guidelines to post the same or similar items more than once in these forums. So, I've closed your other post found here:
http://www.phpfreaks...showtopic=43715

Please read our various forum guidelines.

I also deleted your other post where you had:

ho do i do a varibal plz help i forgot
???

thanks


Which doesn't make any sense by iteself of exactly what you mean. I assume it's regarding this post where you specify $_GET['WHAT DO I PUT HERE'].

If you have PHP version 4.1.0 or higher then use $_SESSION variable instead of session_register() which requires that register_globas be turned on.

Click on the PHP F.A.Q. link below:
http://www.phpfreaks...=0

Look for the $_GET Variables section to learn more.

Read the PHP session tutorial at http://www.phpfreaks...orials/41/0.php but ignore any reference to session_register().

#3 <? ben >?

<? ben >?
  • Members
  • Pip
  • Newbie
  • 3 posts
  • Locationuk

Posted 03 October 2004 - 04:59 PM

the first block of code is my login bit i need help sorting the varibas out coz the 2nd block of code is an update thing which updates the persons profile i need it so they can edit it becaus when they do it shows my deatils go to www.elite-commandos.co.uk and click register then u will be logged in in the topcorner of the page u will be on it says update profile


see 4 ur self

thanks
plz and help Keep Them alive

#4 <? ben >?

<? ben >?
  • Members
  • Pip
  • Newbie
  • 3 posts
  • Locationuk

Posted 03 October 2004 - 05:15 PM

Posted Image


which 1 do i need ??#
plz and help Keep Them alive

#5 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 03 October 2004 - 05:43 PM

You should have let people know that you're using dreamweaver. I've moved your post to this more suitable topic area.

I don't know anything about it. Why don't you just try the various options. It doesn't look that hard. I also don't know whether you're talking about get variable or session variables.

Please note I've update my previous post to inlcude links to stuff for you to read and learn from.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users