This is my code" -
<?php if(!session_start()) { exit(); }else{ session_start(); $sessid = session_id(); }?>
-
// some html code
-
<?
-
// here is part a
-
$_SESSION['x'] = "hello world!"; echo $_SESSION['x'];
-
if (isset($_GET['admin'])) {
-
include("include/admin.inc.php");
-
}else if ($_GET['a'] == "l") {
-
$query = "SELECT * FROM `login_attempt` WHERE ip = '$userip';";
-
$query = mysql_query($query);
-
if(mysql_num_rows($query) == 0) {
-
$query1 = 'INSERT INTO `login_attempt` (`ip` ,`attempt_left` ,`expire`) VALUES ("' . $userip . '", "5", DATE_ADD(NOW(), INTERVAL 1 HOUR));';
-
mysql_query($query1);
-
}
-
if(mysql_num_rows($query) != 0) {
-
while($info = mysql_fetch_array($query)) {
-
$log_left_times = $info['attempt_left'];
-
$log_exp = $info['expire'];
-
}
-
}
-
require('func/CalculateMonthSecond.func.php');
-
$log_exp = str_split($log_exp);
-
$year = $log_exp[0] . $log_exp[1] . $log_exp[2] . $log_exp[3];
-
$month = $log_exp[5] . $log_exp[6];
-
$day = $log_exp[8] . $log_exp[9];
-
$hour = $log_exp[11] . $log_exp[12];
-
$minute = $log_exp[14] . $log_exp[15];
-
$second = $log_exp[17] . $log_exp[18];
-
$y_s = 31536000*$year;
-
$m_s = CalculateMonthSecond($year, $month);
-
$d_s = $day*86400;
-
$h_s = $hour*3600;
-
$m_s2 = $minute*60;
-
$s_s = $second;
-
$expire_second = $y_s+$m_s+$d_s+$h_s+$m_s2+$s_s;
-
$year2 = date('Y');
-
$month2 = date('m');
-
$day2 = date('d');
-
$hour2 = date('H');
-
$minute2 = date('i');
-
$second2 = date('s');
-
$y_s2 = 31536000*$year2;
-
$m_s2 = CalculateMonthSecond($year2, $month2);
-
$d_s2 = $day2*86400;
-
$h_s2 = $hour2*3600;
-
$m_s3 = $minute2*60;
-
$s_s2 = $second2;
-
$now_second = $y_s2+$m_s2+$d_s2+$h_s2+$m_s3+$s_s2;
-
if($expire_second < $now_second) {
-
$query_updEXP = 'UPDATE `login_attempt` SET `attempt_left` = "5"' . ' WHERE `ip` = "' . $userip . '";';
-
mysql_query($query_updEXP);
-
}
-
$query = "SELECT * FROM `login_attempt` WHERE ip = '$userip';";
-
$query = mysql_query($query);
-
if(isset($_POST['account']) && isset($_POST['password'])) {
-
if ($expire_second < $now_second) {
-
$expired = 1;
-
}else{
-
$expired = 0;
-
}
-
$account = SQLInjectionFilter($_POST['account']);
-
$password = hash("sha256", $_POST['password']);
-
$query = "Select * FROM `user` WHERE username = $account AND password = '$password';";
-
$query = mysql_query($query);
-
if($log_left_times <= 0 && $expired == 0) {
-
$query_z = 'update `login_attempt` set `expire` = DATE_ADD(NOW(), INTERVAL 1 HOUR) WHERE `ip` = "' . $userip . '";';
-
mysql_query($query_z);
-
$s = 3;
-
}else if ($log_left_times >= 0 && expired == 1) {
-
if(mysql_num_rows($query) != 0) {
-
$_SESSION['logined'] == '1';
-
$_SESSION['logined_time'] == date("r");
-
$_SESSION['account'] == $_POST['account'];
-
echo $_SESSION['logined'];
-
// here is part b
-
$_SESSION['x'] = "hello world!"; echo $_SESSION['x'];
-
$s = 2;
-
}else{
-
$log_left_times = $log_left_times-1;
-
$query_updEXP_2 = 'UPDATE `login_attempt` SET `attempt_left` = "' . $log_left_times . '"' . ' WHERE `ip` = "' . $userip . '";';
-
$query_updEXP_3 = 'update `login_attempt` set `expire` = DATE_ADD(NOW(), INTERVAL 1 HOUR) WHERE `ip` = "' . $userip . '";';
-
mysql_query($query_updEXP_2);
-
mysql_query($query_updEXP_3);
-
$s = 1;
-
}
-
}else if ($log_left_times > 0) {
-
if(mysql_num_rows($query) != 0) {
-
$_SESSION['logined'] == '1';
-
$_SESSION['logined_time'] == date("r");
-
$_SESSION['account'] == $_POST['account'];
-
echo $_SESSION['logined'];
-
// here is part b
-
$_SESSION['x'] = "hello world!"; echo $_SESSION['x'];
-
$s = 2;
-
}else{
-
$log_left_times = $log_left_times-1;
-
$query_updEXP_2 = 'UPDATE `login_attempt` SET `attempt_left` = "' . $log_left_times . '"' . ' WHERE `ip` = "' . $userip . '";';
-
$query_updEXP_3 = 'update `login_attempt` set `expire` = DATE_ADD(NOW(), INTERVAL 1 HOUR) WHERE `ip` = "' . $userip . '";';
-
mysql_query($query_updEXP_2);
-
mysql_query($query_updEXP_3);
-
$s = 1;
-
}
-
}
-
}
-
require("include/login.inc.php");
-
}else if ($_GET['a'] == "r") {
-
include("include/register.inc.php");
-
}else if ($_GET['a'] == "c") {
-
include("include/contact.inc.php");
-
}else if ($_GET['a'] == "f") {
-
include("include/faq.inc.php");
-
}else if ($_GET['a'] == "t") {
-
include("include/tos.inc.php");
-
}else if ($_GET['a'] == "a") {
-
require ("include/account.inc.php");
-
}else if ($_GET['a'] == "b") {
-
include ("include/banner.inc.php");
-
}else if (!isset($_GET['a']) OR $_GET['a'] == "" OR $_GET['a'] == "h") {
-
include("include/index.inc.php");
-
}
-
?>
-
// some html code
-
in part a, it can print out hello world!, but in part b, it didn't print out anything!
So how to fix this?
Thanks!
my father say
may be your "else" is not match with"if"
check it angin
3 1442
For basic stuff like this, you sometimes have to reduce your code to absolute minimum and hard code some data if needed to try to pin point the problem.
This is a useful skill that all programmers should have, thus you should not be robbed of opportunities to do this yourself.
1. Save this file and rename it as something else
2. Take out all the queries and logic
3. Leave the session code the way it "should" work and debug from there.
Good luck,
Dan
my father say
may be your "else" is not match with"if"
check it angin
Thanks, my problem sloved, also, i want choose both of you as the best ans. but i found it there is some if and else problem in my script, however thanks dan!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roman |
last post by:
Hi,
I've installed .net on my server and since then I'm loosing my
sessions from my (old) asp.
e.g.: Session("test") works on the same page, but if the page is
changed the whole session is...
|
by: David W. Fenton |
last post by:
A very old app of mine that's been in production use, and largely
unchanged since about 1998 has started recently throwing error 3188
(can't update, locked by another session on this machine) when...
|
by: caldera |
last post by:
Hello,
We have a session problem. A dataset is put into a session and call this
session value later. When we run this web page in http://localhost it works.
But server has a specific name like...
|
by: Ryan Moore |
last post by:
I'm using Forms Authentication for user logins in an ASP.NET app.
Is there any way to log out another Session when a user logs in?
Example:
The site only allows 10 users to be logged in at...
|
by: Axel Dahmen |
last post by:
Hi,
today I've had a strange DTS error: In one of my transformations I'd been
using several Copy Column transformations + one ActiveX transformation using
a lookup function. This lookup function...
|
by: alan |
last post by:
Hi, i have some problem in asp.net session problem
in page_load ->
i have
Label1.text = Session("a")
in DataGrid1_sortCommand ->
i have
Session("a") = e.sortExpression
|
by: Mark Reed |
last post by:
Hi All,
I'm having a problem with the following code. I've read quite a lot of
old posts regarding the issue but none seem to affer a solution.
The scenario is. I have a bound form which...
|
by: Access Programming only with macros, no code |
last post by:
ERROR MESSAGE:
Could not update; currently locked by another session on this
machine.
BACKGROUND
I have the following objects:
Table1 - HO (which has about 51,000+ records)
Table2 -...
|
by: beary |
last post by:
Sorry if this seems obvious to some, but
On the "check" page I have
session_start();
$_SESSION=$subjectshort;
$_SESSION='horse';
header( "Location: admin.php" );
|
by: Kong Chun Ho |
last post by:
Hi all,
I have a php session problem when i echo a session_id, it return nothing!
<?php if(!session_start()) { exit(); }else{ ob_start(); session_start(); echo session_id(); echo SID;...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |