PDA

View Full Version : dynamic php code help for login and logout


theman68
06-10-2011, 06:19 PM
ok guys here i am annoying you all again lol
ok well here is the code that im having trouble with can any one help me?



<?php
//initialize the session
if (!isset($_SESSION)) {
session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);

( here is my problem guys )
$logoutGoTo = "Brands.php?recordID=" . $pName_DetailRS1['pName'];
( problem end )

if ($logoutGoTo) {
header("Location: $logoutGoTo");
exit;
}
}
?>
ok well ill explain
im needing to function to echo a command or to be able to define a variable with inthe function from a database, but cos i knwo the database is not defined with in the function then i know i cant just define the string like for ex $logoutsample = $(database value) cos the database has not been defined with in the function bal bal.
im probably rambling on as i dont really know what im talking about as im new to php

all i know is on the page its self all i have to do is to typ ethis to echo the information which i need <?php echo $pName_DetailRS1['pName']; ?> and that get me the value that i need so how do i get this function to put that information there where i need it. thanks for all your help

jmichae3
06-12-2011, 09:17 PM
ok guys here i am annoying you all again lol

all i know is on the page its self all i have to do is to typ ethis to echo the information which i need <?php echo $pName_DetailRS1['pName']; ?> and that get me the value that i need so how do i get this function to put that information there where i need it. thanks for all your help

http://us.php.net/manual/en/function.mysql-query.php
http://us.php.net/manual/en/function.mysql-select-db.php
contains a full example.
you need to do a mysql_connect, then a mysql_connect_db, then your mysql_query, then mysql_fetch_assoc, then mysql_free_result.