Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,786 members, 7,820,754 topics. Date: Tuesday, 07 May 2024 at 08:57 PM

Php Programmer Help Me Out ! - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Php Programmer Help Me Out ! (2194 Views)

Urgently In Need Of An Experience Javascript / PHP Programmer / PHP Programmer Needed Urgently For Employment In Lagos / Php Programmer Need Help (2) (3) (4)

(1) (2) (Reply) (Go Down)

Php Programmer Help Me Out ! by Nobody: 7:54pm On Jul 02, 2015
I develop a dreamweaver login page where a user can be login to my member restricted page using his username and password.

The problem now is that i want to count the number of each user login action into my database.I have already created a table column called 'login_no' into my database table.

I want the 'login_no' colum to count the total number of logins of each user into my restricted page.



PLEASE HELP ME OUT !



See my code below :



login form page code.



<?php require_once('Connections/myconn.php'); ?>

<?php

if (!function_exists("GetSQLValueString"wink) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""wink

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}



$theValue = function_exists("mysql_real_escape_string"wink ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



switch ($theType) {

case "text":

$theValue = ($theValue != ""wink ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != ""wink ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != ""wink ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != ""wink ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != ""wink ? $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=$_POST['password'];

$MM_fldUserAuthorization = "";

$MM_redirectLoginSuccess = "mmember.php";

$MM_redirectLoginFailed = "loginfail.php";

$MM_redirecttoReferrer = false;

mysql_select_db($database_myconn, $myconn);



$LoginRS__query=sprintf("SELECT username, password FROM regtable WHERE username=%s AND password=%s",

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



$LoginRS = mysql_query($LoginRS__query, $myconn) or die(mysql_error());

$loginFoundUser = mysql_num_rows($LoginRS);

if ($loginFoundUser) {

$loginStrGroup = "";



if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}

//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 );

}

}

?>

my member restricted page code.

<?php require_once('Connections/myconn.php'); ?>

<?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'] != ""wink){

$logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);

}



if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true"wink){

//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 = "mlogin.php";

if ($logoutGoTo) {

header("Location: $logoutGoTo"wink;

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 == ""wink && true) {

$isValid = true;

}

}

return $isValid;

}



$MM_restrictGoTo = "mlogin.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, "?"wink) $MM_qsChar = "&";

if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)

$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];

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

header("Location: ". $MM_restrictGoTo);

exit;

}

?>

<?php

if (!function_exists("GetSQLValueString"wink) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = ""wink

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}



$theValue = function_exists("mysql_real_escape_string"wink ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);



switch ($theType) {

case "text":

$theValue = ($theValue != ""wink ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != ""wink ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != ""wink ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != ""wink ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != ""wink ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}



$colname_Recordset1 = "-1";

if (isset($_SESSION['MM_Username'])) {

$colname_Recordset1 = $_SESSION['MM_Username'];

}

mysql_select_db($database_myconn, $myconn);

$query_Recordset1 = sprintf("SELECT * FROM reg WHERE username = %s", GetSQLValueString($colname_Recordset1, "text"wink);

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

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);



$colname_Recordset1 = "-1";

if (isset($_SESSION['MM_Username'])) {

$colname_Recordset1 = $_SESSION['MM_Username'];

}

mysql_select_db($database_myconn, $myconn);

$query_Recordset1 = sprintf("SELECT * FROM regtable WHERE username = %s", GetSQLValueString($colname_Recordset1, "text"wink);

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

$row_Recordset1 = mysql_fetch_assoc($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">

body,td,th {

font-size: 16px;

}

</style>

</head>



<body>

<p style="font-size: 18px">welcome <span style="font-weight: bold"><?php echo $row_Recordset1['username']; ?></span> to our member page !

you just log in now. </p>

<p> </p>

<p> </p>

<p><a href="<?php echo $logoutAction ?>">LOG OUT</a></p>

</body>

</html>

<?php

mysql_free_result($Recordset1);

?>
Re: Php Programmer Help Me Out ! by Nobody: 8:27pm On Jul 02, 2015
I don lost. . . .for code
Re: Php Programmer Help Me Out ! by talk2hb1(m): 8:53pm On Jul 02, 2015
This your code in incomprehensible, If I understand what you are trying to achieved. You are trying to keep track of the number login attempt by a user? If that should be the case, all you need to do is create another table to keep track of login and keep a session for an individual on their login attemp.
Re: Php Programmer Help Me Out ! by Craigston: 12:37am On Jul 03, 2015
Your code is really intimidating. You can remove the style section since we don't really need it.

I think you can achieve your aim by creating a column in your table for login count, say 'login_count'.
Then issue a query with each login to increment the value. Take
$query_login_increment = "UPDATE table_name SET login_count = login_count + 1 WHERE user = $username";
Ensure you fix any errors.

1 Like

Re: Php Programmer Help Me Out ! by Nobody: 1:55am On Jul 03, 2015
^^The two guys above me are more intelligent than me, I just saw plenty codes and ran for my life!

1 Like

Re: Php Programmer Help Me Out ! by guente02(m): 3:32am On Jul 03, 2015
Hmmmm.
Dat code is longer the river nile o connected from Atlanta to Okokomaiko
Re: Php Programmer Help Me Out ! by jacob05(m): 3:57am On Jul 03, 2015
***Dream walks into the thread ***
***Steps Out***
Re: Php Programmer Help Me Out ! by Nobody: 5:20am On Jul 03, 2015
I used to think I was super-ted and can handle any code thrown at me. . . . .but this one pass my power!
Re: Php Programmer Help Me Out ! by seunthomas: 8:06am On Jul 03, 2015
dhtml18:
I used to think I was super-ted and can handle any code thrown at me. . . . .but this one pass my power!
You be rookie then.
Re: Php Programmer Help Me Out ! by Nobody: 8:25am On Jul 03, 2015
NOOB! na im i be!
Re: Php Programmer Help Me Out ! by Craigston: 8:59am On Jul 03, 2015
dhtml18:
I used to think I was super-ted and can handle any code thrown at me. . . . .but this one pass my power!
Hahahahahaha. Oga dhtml18. E don tey. How u dey na? Ministry (Nairaland) dey grow well?
You and trolling sha. Just watch out for mods o. Oops! Duck. That was a mod about to throw a ban!

But try help the guy na. Bosses like you should help us as much as you can.
Re: Php Programmer Help Me Out ! by Nobody: 9:36am On Jul 03, 2015
^^^Nairaland has died, it shall be resurrected again. . . . .in due time

1 Like

Re: Php Programmer Help Me Out ! by talk2hb1(m): 3:44pm On Jul 03, 2015
dhtml18:
^^The two guys above me are more intelligent than me, I just saw plenty codes and ran for my life!
lipsrsealed undecided lipsrsealed undecided lipsrsealed undecided
Re: Php Programmer Help Me Out ! by trytillmake(m): 4:47pm On Jul 03, 2015
dhtml18:
^^The two guys above me are more intelligent than me, I just saw plenty codes and ran for my life!

guente02:
Hmmmm.
Dat code is longer the river nile o connected from Atlanta to Okokomaiko

grin grin grin grin grin
Re: Php Programmer Help Me Out ! by Nobody: 11:07pm On Jul 04, 2015
dhtml18:
I used to think I was super-ted and can handle any code thrown at me. . . . .but this one pass my power!
Oga Anthony you too wicked. You no gree help and u still dey take style yab people. I go report u to Buhari o
Re: Php Programmer Help Me Out ! by Nobody: 11:30pm On Jul 04, 2015
^^^I no sabi the code ni o, no be my fault at all.
Re: Php Programmer Help Me Out ! by 53cur3m0d3(m): 12:43am On Jul 05, 2015
This guy just buy 6 acres of virgin land take code
Re: Php Programmer Help Me Out ! by Craigston: 4:47am On Jul 05, 2015
gearcoin, I'd like to help but my laptop's screen just went bad so I can't test anything. Let's see what we can do here.
Your code is a little insecure and it has many unnecessary parts. Have you solved the problem?
Re: Php Programmer Help Me Out ! by Nobody: 7:18am On Jul 05, 2015
^^^Just tell us the truth, na the gaddamn code spoil your screen. . .

1 Like

Re: Php Programmer Help Me Out ! by Craigston: 8:16am On Jul 05, 2015
dhtml18:
^^^Just tell us the truth, na the gaddamn code spoil your screen. . .
Hahahahahahahahahahahahahahahaha.
*hmmm!
This one is strong eh.
I don't know what's fucking up my screen. I used the laptop to study until about 1am, played a game and put it on sleep so I'd continue where I left. I woke up later to study and, shit! The screen showed me a pink hue. Now it's turned dark gray so I can't see through but it works fine on an external monitor.
Re: Php Programmer Help Me Out ! by Craigston: 8:20am On Jul 05, 2015
Btw, where this OP go?
OP, you created a thread and, while you have some audience, you remain mute? Abi d cold code don hibernate you?
Re: Php Programmer Help Me Out ! by Nobody: 11:28am On Jul 05, 2015
^^^ MegaBytes don finish. . . .
Re: Php Programmer Help Me Out ! by Ebenstyles(m): 10:41am On Jul 07, 2015
@OP. start using mysqli and let mysql be, your code doesn't look nice. *though will look cool in the eyes of a malicious user.

1 Like

Re: Php Programmer Help Me Out ! by Nobody: 3:39pm On Jul 07, 2015
dhtml18:
I don lost. . . .for code

oga ! i have removed the unnecessary code.

you are very funny o.
Re: Php Programmer Help Me Out ! by Nobody: 3:42pm On Jul 07, 2015
Thanks every body !

IT IS TODAY THAT I KNOW THAT THERE ARE SOME HIDDEN WEB PROGRAMMERS. IT IS JUST THAT THEY DONT EVEN COMMENT ANY HOW.

THANKS EVERYBODY. I HAVE REDIT THE CODE.
Re: Php Programmer Help Me Out ! by Nobody: 3:45pm On Jul 07, 2015
Craigston:
gearcoin, I'd like to help but my laptop's screen just went bad so I can't test anything. Let's see what we can do here.
Your code is a little insecure and it has many unnecessary parts. Have you solved the problem?

OGA CRAIGSTON ! I HAVE REMOVED ALL THE UNNESSARY CODE. I HAVE RESOLVED HALF OF THE PROBLEM.YOU CAN STILL HELP.
Re: Php Programmer Help Me Out ! by Nobody: 3:53pm On Jul 07, 2015
I read the codes again, e long like Agege to Abuja, mba, i no fit solve am. . . .
Re: Php Programmer Help Me Out ! by Nobody: 3:56pm On Jul 07, 2015
dhtml18:
^^^ MegaBytes don finish. . . .

NO ! AM USING MTN UNLIMITED. YOUR HELP IS NEEDED IF YOU CAN DO IT.
Re: Php Programmer Help Me Out ! by Nobody: 3:57pm On Jul 07, 2015
dhtml18:
I read the codes again, e long like Agege to Abuja, mba, i no fit solve am. . . .

OK. THANKS.
Re: Php Programmer Help Me Out ! by Nobody: 4:04pm On Jul 07, 2015
Craigston:
Your code is really intimidating. You can remove the style section since we don't really need it.

I think you can achieve your aim by creating a column in your table for login count, say 'login_count'.
Then issue a query with each login to increment the value. Take
$query_login_increment = "UPDATE table_name SET login_count = login_count + 1 WHERE user = $username";
Ensure you fix any errors.

YES ! YES !

GUY ! YOU ARE TOO MUCH. THIS IS EXACTLY WHAT I DID AND IT WORKS PERFECTLY.

I ONLY WANT TO SOLVE ONE INTERNAL ERROR THAT ERUPTED.

THANKS GUY .
Re: Php Programmer Help Me Out ! by Nobody: 4:06pm On Jul 07, 2015
Ebenstyles:
@OP. start using mysqli and let mysql be, your code doesn't look nice. *though will look cool in the eyes of a malicious user.
NOTED ! THANKS.

I THINK DREAMWEAVER ALWAYS NOT WRITE IN MYSQLI.
I WILL FIND A WAY TO CONVERT IT LATER. THANKS.
Re: Php Programmer Help Me Out ! by Nobody: 4:23pm On Jul 07, 2015
talk2hb1:
This your code in incomprehensible, If I understand what you are trying to achieved. You are trying to keep track of the number login attempt by a user? If that should be the case, all you need to do is create another table to keep track of login and keep a session for an individual on their login attemp.

THANKS FOR COMMENT ! NOT LIKE THAT.
I JUST WANT TO COUNT THE LOGIN TIME EACH USER LOGIN TO MY RESTRICTED MEMBER PAGE.

(1) (2) (Reply)

BUY Silent Office Exploit (6 CVE) / Write Pdf Files With Vb 6.0 / Programming Tutor Needed

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 46
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.