Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 87055

Hello I need help for my user profile page

$
0
0

Hi people. I am using Dreanweaver for creating dynamic website. Now im creating test pages. I successfully created login, registration, index pages. Its worked. But im trying to create user profile page. But i dont know how to get user information from mysql table. I attached my php working file. Please anyone create user profile page for me?

 

My index.php script

<?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']);

 

  $logoutGoTo = "login.php";

  if ($logoutGoTo) {

    header("Location: $logoutGoTo");

    exit;

  }

}

?>

<?php

if (!isset($_SESSION)) {

  session_start();

}

$MM_authorizedUsers = "";

$MM_donotCheckaccess = "true";

 

 

// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {

  // For security, start by assuming the visitor is NOT authorized.

  $isValid = False;

 

 

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.

  // Therefore, we know that a user is NOT logged in if that Session variable is blank.

  if (!empty($UserName)) {

    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.

    // Parse the strings into arrays.

    $arrUsers = Explode(",", $strUsers);

    $arrGroups = Explode(",", $strGroups);

    if (in_array($UserName, $arrUsers)) {

      $isValid = true;

    }

    // Or, you may restrict access to only certain users based on their username.

    if (in_array($UserGroup, $arrGroups)) {

      $isValid = true;

    }

    if (($strUsers == "") && true) {

      $isValid = true;

    }

  }

  return $isValid;

}

 

 

$MM_restrictGoTo = "login.php";

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  

  $MM_qsChar = "?";

  $MM_referrer = $_SERVER['PHP_SELF'];

  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";

  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)

  $MM_referrer .= "?" . $QUERY_STRING;

  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);

  header("Location: ". $MM_restrictGoTo);

  exit;

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

<!--

#apDiv1 {

  position:absolute;

  left:358px;

  top:52px;

  width:595px;

  height:417px;

  z-index:1;

}

-->

</style>

</head>

 

 

<body>

<div id="apDiv1">

  <p>Welcome Mr. <a href="<?php echo $logoutAction ?>">Log out</a></p>

  <p><?php echo $_SESSION['name']; ?></p>

  <p> </p>

</div>

</body>

</html>

 

 

My register.php script

 

<?php require_once('Connections/new.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;

}

}

 

 

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}

 

 

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

  $insertSQL = sprintf("INSERT INTO users (name, email, passward) VALUES (%s, %s, %s)",

                       GetSQLValueString($_POST['name'], "text"),

                       GetSQLValueString($_POST['email'], "text"),

                       GetSQLValueString($_POST['passward'], "text"));

 

 

  mysql_select_db($database_new, $new);

  $Result1 = mysql_query($insertSQL, $new) or die(mysql_error());

 

 

  $insertGoTo = "login.php";

  if (isset($_SERVER['QUERY_STRING'])) {

    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

    $insertGoTo .= $_SERVER['QUERY_STRING'];

  }

  header(sprintf("Location: %s", $insertGoTo));

}

 

 

mysql_select_db($database_new, $new);

$query_Recordset1 = "SELECT * FROM users";

$Recordset1 = mysql_query($query_Recordset1, $new) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

<!--

#apDiv1 {

  position:absolute;

  left:358px;

  top:52px;

  width:595px;

  height:417px;

  z-index:1;

}

-->

</style>

</head>

 

 

<body>

<div id="apDiv1">

  <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">

    <table width="500" height="271" border="0">

      <tr>

        <td width="247"><label>Name</label></td>

        <td width="243"><input type="text" name="name" id="name" /></td>

      </tr>

      <tr>

        <td><label>E-mail</label></td>

        <td><input type="text" name="email" id="email" /></td>

      </tr>

      <tr>

        <td><label>Passward</label></td>

        <td><input type="text" name="passward" id="passward" /></td>

      </tr>

      <tr>

        <td> </td>

        <td><label>

          <input type="submit" name="submit" id="submit" value="Register" />

        </label>

          <a href="#">Login </a></td>

      </tr>

    </table>

    <input type="hidden" name="MM_insert" value="form1" />

  </form>

</div>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?>

 

My login.php script

 

<?php require_once('Connections/new.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['email'])) {

  $loginUsername=$_POST['email'];

  $password=$_POST['passward'];

  $MM_fldUserAuthorization = "";

  $MM_redirectLoginSuccess = "index.php";

  $MM_redirectLoginFailed = "deneid.php";

  $MM_redirecttoReferrer = false;

  mysql_select_db($database_new, $new);

 

  $LoginRS__query=sprintf("SELECT email, passward FROM users WHERE email=%s AND passward=%s",

    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

  

  $LoginRS = mysql_query($LoginRS__query, $new) 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 );

  }

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

<!--

#apDiv1 {

  position:absolute;

  left:361px;

  top:118px;

  width:595px;

  height:305px;

  z-index:1;

}

#apDiv2 {

  position:absolute;

  left:372px;

  top:79px;

  width:574px;

  height:34px;

  z-index:2;

}

-->

</style>

</head>

 

 

<body>

<div id="apDiv1">

  <form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">

    <table width="500" height="271" border="0">

 

 

      <tr>

        <td width="247"><label>E-mail</label></td>

        <td width="243"><input type="text" name="email" id="email" /></td>

      </tr>

      <tr>

        <td><label>Passward</label></td>

        <td><input type="text" name="passward" id="passward" /></td>

      </tr>

      <tr>

        <td> </td>

        <td><label>

          <input type="submit" name="submit" id="submit" value="login" />

        </label>

          <a href="register.php">Register</a></td>

      </tr>

    </table>

  </form>

</div>

</body>

</html>

 

Anyone give me script for user profile page?


Viewing all articles
Browse latest Browse all 87055

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>