Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-03-2008, 05:54 PM
  #16
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
First off, thank you "DaiWelsh" for your explanation of a session.. This stuff is starting to become somewhat familiar now and making some sense.. its reminding me of C and Java a little that i took like 4 yrs ago in high school.

Second, pual, thank you for taking the time to look at my code, and yes it is from a third party.
your disclaimer is very well put, haha, im willing to try anything, i saved all my old stuff incase things get too ugly i can just put everything back the way i had it before, so don't worry about screwing the code up.

i made the changes that you said and i am getting this error when trying to login now...
Quote:
A system error occurred. We apologize for the inconvenience.

A system error occurred. We apologize for the inconvenience.

A system error occurred. We apologize for the inconvenience.

A system error occurred. We apologize for the inconvenience.

Please try again.
A system error occurred. We apologize for the inconvenience.
any ideas why?
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-04-2008, 10:46 AM
  #17
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
I'm actually in London doing some client work at the moment, so I don't have the time to specd on this right now. So if I could alsk the admins to take a look at what I wrote and fix whatever I messed up... thanks!
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-05-2008, 12:14 AM
  #18
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
Oh, no problem paul.. Have fun in london, Thanks for all your help. I will try to do some of my own research, like i have already been doing and try to figure some of it out also.. In the meantime, yes, if anyone else could help, that would be greatly appriciated.. thanks..
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-06-2008, 05:39 PM
  #19
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
Did you get this sorted? I would be happy to help you out further if you didn't.

I would recommend taking a step back from using a load of (badly written) 3rd party scripts and start very very simply under your own steam from the beginning.

If you are not comfortable with HTML then that would be the best place to begin, followed by an understanding of CSS and then get to PHP. From there just start testing simple things until the concepts / functions become trivial and familiar... e.g.

PHP Code:
<?php

for($i 0$i 200$i++)
{
       
$size rand(1024);
       
$colour 'rgb('.rand(0255).', '.rand(0255).', '.rand(0255).')'

       echo 
'<span style="font-size: '.$size.'px; color: '.$colour.'">Learn the basics first!! </span>';
}

?>
illustrates how a simple PHP loop can leverage HTML and CSS to do something useless and annoying, but fun...

Then try to make a static site. Then a simple dynamically generated series of pages. Then add a login. Then a contact form. Then multiple types of user. You get the idea. BUT DO IT YOURSELF - don't download scripts and try to undertand straight away! Download them for inspiration, but rewrite them in your own way.

It will take less time than you would think! Good luck.

Paul
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand

Last edited by paul_norman_81 : 09-06-2008 at 05:43 PM.
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-08-2008, 01:47 AM
  #20
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
i guess i could do that.. i know that would definatly be the best thing in the long run to do.

i am just so eager to actually start using my website, that its hard to have to wait until i learn it all.

thanks for the tips paul...

any recommendations on what i should read to start learning all this? (specific website, or book, video, etc).

so should i change back all the things u wrote for now?
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-09-2008, 05:35 AM
  #21
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
To fix the profile.php page that I wrote (just typos and oversight on my behalf - sorry) use the code below - you will also need to pull out first_name and user_level to session variables in the login.php script (just like I did with user_id):

PHP Code:
<?php
    
# The session must now start in here as the header has been moved down!
    
require_once('includes/config.inc.php');

    
# Initialise the local $user_id variable as null
    
$user_id null;

    
# If we have a session use that as our $user_id
    
if(isset($_SESSION['user_id']))
    {
        
$user_id = (int)$_SESSION['user_id'];
    }

    
# If we are viewing someone else use that as our $user_id
    
if(isset($_GET['user_id']))
    {
        
$user_id = (int)$_GET['user_id'];
    }

    
# We potentially have a user and need to check the database
    
if(!is_null($user_id))
    {
        require_once(
MYSQL);

        
$sql "SELECT        first_name, 
                            last_name 
                
                FROM        users 
                
                WHERE        user_id = "
.$user_id;
        
$result mysqli_query($dbc$sql);

        if(@
mysqli_num_rows($result) == 1)
        {
            while(
$row mysqli_fetch_assoc($result))
            {
                
$page_title        $row['first_name'].' '.$row['last_name'].'\'s Profile';
                
$page_content    '<pre>'.print_r($rowtrue).'</pre>';
            }
        }
        else
        {
            
# User id not found - ERROR
            
$page_title        'User Not Found';
            
$page_content    '<p>Sorry, that user could not be found!</p>';
        }

        
mysqli_free_result($result);
        
mysqli_close($dbc);
    }
    else
    {
        
# No user id specified - ERROR
        
$page_title        'User ID Required';
        
$page_content    '<p>Sorry, that you must pass a user id to this script!</p>';
    }

    include(
'includes/header.html');

    echo 
$page_content;

    include(
'includes/footer.html');

?>
I started with heavily HTML sites in the era before CSS was common and tables were rampant, so I just stumbled into PHP when I hit the stage that I wanted to do something that I could not do with HTML - I had no reliable internet access (not even 56k) so all my stuff was offline and pretty lame.

I was lucky in that I had a friend who encouraged me to mess with web things and helped me out with the theory, but this is uncommon I think. Although problem solving with friends is by far my preferred method of learning a challenging topic! If you struggle though something you really do get to learn it!

The issue with online php tutorials is that they either list an overwhelming number of functions (e.g. wc3 / the php manual) and somehow expect you to remember them (and know when to use them) OR they are just a collection of "make a contact-us form" or "pulling users from the database" guides IN NO ORDER which are useful (esp for advanced topics), but only if you are doing that task (unless you love reading everything). There isn't much focused on getting beginners off the ground in their first few weeks and guiding them alon a useful path to building a functional / secure website step by step. I guess fora like this one are the best bet for this at the moment.

I suppose that a book would be the best place to start if you are serious and want the guided experience. I'm afraid I don't own any PHP (or coding books) so it is difficult for me to recommend them, but I'm sure Amazon etc will have useful reviews attached to any books they sell.

Other forum members will likely be able to help you with advice on this better than I can.
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 02:19 PM
  #22
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
Hello everyone. Especially Paul.

sorry, I havn't replyed in soo long. I was in the hospital for like a week. I just got released yesterday. I'm all better now though, just some type of staff infection my leg that was spreading.

Anyways, Paul,
I changed the profile.php page to the new changes but i dont know what you meant when you said:
Quote:
you will also need to pull out first_name and user_level to session variables in the login.php script (just like I did with user_id):

ive been trying to read some html tutorials, it looks like its ganna take me a long while before im good at all this
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 02:45 PM
  #23
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
Sorry to hear that you were in hospital, but glad to hear that you are better now .

Just to finish up that bit of code the following needs to be in the login.php file where previously we only set the user_id.

PHP Code:
# Just store what you need (you may want more than this!)
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['first_name'] = $row['first_name']; 
$_SESSION['user_level'] = $row['user_level']; 
Learning development skills does take time, but it is worth it in the long run!
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 04:07 PM
  #24
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
Thanks, U forget how nice it is to not be trapped in a small room after a week.
Especially without internet... VERRRRYYYY BORINGGGG!

hmmm, i added those 2 lines of code in the login.php page, but
when i try to login on the website, it still is not letting me...

i get an error that says:
Quote:
A system error occurred. We apologize for the inconvenience.
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 04:14 PM
  #25
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
i was just thinking, do i need to create any new databases for this to work?
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 04:20 PM
  #26
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
To locate the error update your error handling function in includes/config.inc.php. The line to change is:

PHP Code:
if (!LIVE) { // Development (print the error). 
to be

PHP Code:
if(LIVE) { // Development (print the error). 
This will show the actual errors on the screen - remember to put it back once you make your code live!

Also remember to put the session_start() function into that file (anywhere) and remove it from header.html.
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 04:30 PM
  #27
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
okay, so i moved this code:
Code:
// Start output buffering:
ob_start();
from header.html
to
config.inc.php

and then i also took away the "!" in that line of code u told me...

when i try loggin in it still tells me the same thing though, it doesnt show the actual error..
i get:
Quote:
A system error occurred. We apologize for the inconvenience.
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 04:39 PM
  #28
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
Waittt!! Disregard My Previous Reply

I just noticed that i have a config.inc.php and a config2.inc.php

i removed the "!" from config2.inc.php also,
and i added the start function to config.inc.php

when i try to login now, i get this error:
(its in the attached file, because it was too big to post on here)
Attached Files
File Type: txt Error when trying to login.txt (45.6 KB, 11 views)
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 05:08 PM
  #29
paul_norman_81
Guru (Moderator)
 
paul_norman_81's Avatar
 
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
iTrader: (0)
paul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the roughpaul_norman_81 is a jewel in the rough
you want to move session_start(); and not ob_start(); The former allows you to use session variables and the latter stops any content being shown on the screen. The way it is being used here is quite scruffy (and not to be replicated!), but it works for the rest of your scripts so I have left it.

The error seems to be that your mysql login details are incorrect. You must make sure that you have entered the correct user / password / host / database info. The instruction file with your scripts contains this guide.
__________________
"Aut viam inveniam aut faciam" - I'll either find a way or make one

First Tutors | First Tutors: Music | First Tutors: I.T. | First Tutors: Languages | First Tutors: Business | First Tutors: Arts & Crafts | First Tutors: New Zealand
paul_norman_81 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 06:13 PM
  #30
jgray805
Veteran (Level 7)
 
Join Date: Jul 2008
Posts: 61
iTrader: (0)
jgray805 is an unknown quantity at this point
ya, i changed that (ob_start() back the way it was, As soon as i did it i realized i moved the wrong code.


i am 100% sure i am typing in the right user name and password

wut do u mean by make sure the host and data info is right?

what is that?
jgray805 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 11:10 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.