 |
|
|
09-03-2008, 05:54 PM
|
|
#16
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-04-2008, 10:46 AM
|
|
#17
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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!
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-05-2008, 12:14 AM
|
|
#18
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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..
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-06-2008, 05:39 PM
|
|
#19
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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(10, 24);
$colour = 'rgb('.rand(0, 255).', '.rand(0, 255).', '.rand(0, 255).')';
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
Last edited by paul_norman_81 : 09-06-2008 at 05:43 PM.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-08-2008, 01:47 AM
|
|
#20
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-09-2008, 05:35 AM
|
|
#21
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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($row, true).'</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.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 02:19 PM
|
|
#22
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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 
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 02:45 PM
|
|
#23
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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!
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 04:07 PM
|
|
#24
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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.
|

|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 04:14 PM
|
|
#25
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
i was just thinking, do i need to create any new databases for this to work?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 04:20 PM
|
|
#26
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 04:30 PM
|
|
#27
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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.
|
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 04:39 PM
|
|
#28
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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)
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 05:08 PM
|
|
#29
|
 |
|
Guru (Moderator)
Join Date: Nov 2005
Location: Preston, England, UK
Posts: 1,044
|
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.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
09-17-2008, 06:13 PM
|
|
#30
|
 |
|
Veteran (Level 7)
Join Date: Jul 2008
Posts: 61
|
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?
|
|
Add to del.icio.us
Can you digg it?
|
|
 |
|
|
KEEP TABS |
|
SPONSORS |
| |
|
| |
|
|
| |
|