Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,522 members, 7,999,335 topics. Date: Monday, 11 November 2024 at 03:20 AM

Webmasters Help To Check What's Wrong With This Code. - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Webmasters Help To Check What's Wrong With This Code. (724 Views)

How To Check What Technology A Website Is Built With. / Pls, Dear Nairaland Webmasters, Help Me Review My Website. / :-[webmasters Help Need Urgently! (2) (3) (4)

(1) (Reply) (Go Down)

Webmasters Help To Check What's Wrong With This Code. by DaPinkHackeR(m): 2:28pm On Nov 30, 2013
I don't know much about php but am trina work on this site, the problem with the code is that a user will be online but when ever he click on the link to the code or other links too it returns an error message that user is not logged in.

<?php
error_reporting(0) ;
require_once"./includes/functions/gzip.php" ;
include('start.php') ;
include("config.php" ) ;
include("./includes/".$ver."/banned" ) ;

$bots = file("bots/bots.dat" ) ;

$nocache = rand(10000, 99999) ;

list($msec, $sec) = explode(chr(32), microtime());
$headtime = $sec + $msec;

switch($ver)
{
case 'html':
$my_title = "Mysite tittle ";
if(!isset($_COOKIE['theme'])) $_COOKIE['theme'] = 1;
include_once "themes/".intval($_COOKIE['theme'])."/index.php";

//AUTH
$id = intval($_SESSION['id']) ;
$password = mysql_escape_string($_SESSION['password']) ;
$q = mysql_query("SELECT `id` FROM `chat_users` WHERE `id` = '".$id."' AND `password` = '".md5($password)."';" ) ;
if(mysql_num_rows($q) == 0)
{
echo "<small>Sorry you are not logged in!</small><br/>\n";
include_once "themes/".intval($_COOKIE['theme'])."/foot.php";
exit() ;
}
//END AUTH

//ONLINE
$online = time() + 60;
$update = mysql_query("UPDATE `chat_users` SET `time` = '".$online."', `place` = 0, `ip` = '".getenv('REMOTE_ADDR')."', `ua` = '".htmlspecialchars(getenv('HTTP_USER_AGENT'))."' WHERE `id` = '".$id."';" ) ;
//END ONLINE

echo "<form action=\"intim.php?ver=html&amp;nocache=$nocache&amp;".SID."\" method=\"post\">\n";
echo "Enter key*:<br/>\n";
echo "<input type=\"text\" name=\"key\" maxlength=\"10\" /><br/>\n";
echo "<input type=\"submit\" value=\"Enter\" /></form>\n";
echo "* key can only contain letters, and numbers. The length of the key should not be more than 10 characters.<br/>\n";
echo "<a href=\"menu.php?".SID."&amp;ver=html&amp;nocache=$nocache\">Portal</a><br/>\n";
list($msec, $sec) = explode(chr(32), microtime());
echo "<br/><span style=\"font-size: small\">[".round(($sec+$msec)-$headtime,5)."] sec</span><br/>\n";
echo "</body></html>";
break;
}
?>
Re: Webmasters Help To Check What's Wrong With This Code. by brushesz: 5:21pm On Dec 18, 2013
What is the error message?

Your code is not commented and so I can't really comprehend much.

Try to make your programming at least a bit Object Oriented so that you can easily debug
Re: Webmasters Help To Check What's Wrong With This Code. by IamGodzilla: 3:59am On Dec 19, 2013
Well, looking at your scrambled codes( no offence)..
Your using sessions, cookies and your error reporting is turned off
..
1. Check that the sessions are well connected with the users details from the database..
E.g $_Session['Id'] = $id (from database);

2. If your script is dependent on cookies, I.e if ur saving user information with cookies...
If the browser cookie is not turned on you might be having issues like that.

Also make sure the cookies aren't expiring early wich could be d one logging the user out.


3. Remove the code error_reporting(0)..for now till you are done debugging. because it will not show errors.

4. I can see a part of $online..which uses time... Make sure its not the timing that might be the cause.the " 60" there might be 60seconds or 1hr...

I hope it helps because I can't really understand d code.

1 Like

Re: Webmasters Help To Check What's Wrong With This Code. by DaPinkHackeR(m): 5:54pm On Dec 20, 2013
Iam_Godzilla: Well, looking at your scrambled codes( no offence)..
Your using sessions, cookies and your error reporting is turned off
..
1. Check that the sessions are well connected with the users details from the database..
E.g $_Session['Id'] = $id (from database);

2. If your script is dependent on cookies, I.e if ur saving user information with cookies...
If the browser cookie is not turned on you might be having issues like that.

Also make sure the cookies aren't expiring early wich could be d one logging the user out.


3. Remove the code error_reporting(0)..for now till you are done debugging. because it will not show errors.

4. I can see a part of $online..which uses time... Make sure its not the timing that might be the cause.the " 60" there might be 60seconds or 1hr...

I hope it helps because I can't really understand d code.
Thanks any way, i gat more coding to do.
Re: Webmasters Help To Check What's Wrong With This Code. by cbrass(m): 6:46pm On Dec 21, 2013
It looks like you just copied and pasted this code from somewhere...no offence please cos we all do it too
I don't see a session being started here add session_start() at the top of the code I.e <?php session_start(); your codes are here >

Please always comment on your codes..it helps a great deal
Re: Webmasters Help To Check What's Wrong With This Code. by cbrass(m): 6:53pm On Dec 21, 2013
Remove mysql_real_escape_string from the password and put md5() instead, because you didn't hash the password from the begining but you are sending a sql query to the database to fetch a password that was hatched so it can never work like that.I.e md5($_POST["password"])) and not mysql_real_escape_string($_POST["password"])
Re: Webmasters Help To Check What's Wrong With This Code. by DaPinkHackeR(m): 10:08am On Dec 25, 2013
Thank you

(1) (Reply)

Who Is To Be Held Responsible When A Website Is Used For Fraud Purposes? / URGENT!! Calling On Serious Programmers Urgently / .

(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. 20
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.