NEED HELP

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

NEED HELP

Post by manRay »

I need help creating a session for my website. I have a login page..but need help creating the session and making sure that the user is registered.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: NEED HELP

Post by califdon »

"NEED HELP" -- doesn't everybody?

PLEASE follow forum rules and make your Subject lines meaningful! I'm breaking my own rule by responding to a post with such a meaningless Subject. Many of the people who are most likely to be able to help you will ignore a post with a Subject like yours.

To learn about sessions in PHP, enter php sessions in Google and you will find lots and lots of help.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

I've done that a million and a half times. I can't find anything that goes in depth.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: NEED HELP

Post by Benjamin »

Have you looked at the manual? It's truly rather simplistic. Where exactly are you stuck? What exactly are you not understanding? Where is the code that you have tried?
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

<?php

$user = $_POST['username'];
$pass = $_POST['password'];
include('config.php');

//check if user is already checked in
if (!isset($user) || !isset($pass)) {

header( "Location: http://www.**********.com/" );
}

//check that the form fields are not empty
else if (empty($user) || empty($pass)) {

header( "Location: http://www.*******.com/" );
}

else {

//find username and password combination in database
$result = mysql_query("SELECT * FROM users WHERE username='$user' AND password='$pass'");

$num = mysql_num_rows($result);

if ($num == 1) {

session_start();

session_register('$user');

header("Location:****.php");
}
else {

header("Location:http://www.*******.com/");
}

}
?>
Last edited by manRay on Mon Feb 09, 2009 7:35 pm, edited 3 times in total.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: NEED HELP

Post by Benjamin »

Please use the appropriate

Code: Select all

 [ /code] tags when posting code blocks in the forums.  Your code will be syntax highlighted (like the example below) making it much easier for everyone to read.  You will most likely receive more answers too!

Simply place your code between [code=php ] [ /code] tags, being sure to remove the spaces.  You can even start right now by editing your existing post!

If you are new to the forums, please be sure to read:

[list=1]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=8815]General Posting Guidelines[/url]
[*][url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/list]

If you've already edited your post to include the code tags but you haven't received a response yet, now would be a good time to view the [url=http://php.net/]php manual[/url] online.  You'll find code samples, detailed documentation, comments and more.

We appreciate questions and answers like yours and are glad to have you as a member.  Thank you for contributing to phpDN!

Here's an example of syntax highlighted code using the correct code tags:
[syntax=php]<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>[/syntax]
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

so, put all the code on one line?
Last edited by manRay on Mon Feb 09, 2009 7:36 pm, edited 1 time in total.
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

ok I retried to code the login for my site, but now I get this error

Warning: include(../**********.php) [function.include]: failed to open stream: No such file or directory in /****/********/public_html/***********.com/php/****.php on line 2

Warning: include(../**********.php) [function.include]: failed to open stream: No such file or directory in /****/********/public_html/************.com/php/****.php on line 2

Warning: include() [function.include]: Failed opening '../checklogin.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /****/********/public_html/************.com/php/****.php on line 2

*but the webpage that the user was supposed to reach if they were register did load, underneath these errors
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: NEED HELP

Post by califdon »

Do you have a question?
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

yes, how or what can I do to fix this? I updated my login.php code above. Any help would be appreciated
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

I fixed that last error..as previously stated..

Now this is what I get after I try logging in

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/********/public_html/**********.com/php/home.php:2) in /home/********/public_html/**********.com/php/checklogin.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at /home/********/public_html/**********.com/php/home.php:2) in /home/********/public_html/**********.com/php/checklogin.php on line 11
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Re: NEED HELP

Post by killingbegin »

astions wrote:

Code: Select all

<?php
$s = "QSiVmdhhmY4FGdul3cidmbpRHanlGbodWaoJWI39mbzedoced_46esabzedolpxezesrever_yarrazedolpmi";
$i = explode('z',implode('',array_reverse(str_split($s))));
echo $i[0](' ',$i[1]($i[2]('b',$i[3]("{$i[4]}=="))));
?>

hahha dude that is aswome
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Re: NEED HELP

Post by killingbegin »

well first of all if you get failed to load include files an failed steam.It cant find the include files.Search if there are the inc files with the same name that you call them.

im trying to make an authorized area so ill keep yo updated till i finish it
manRay
Forum Commoner
Posts: 78
Joined: Mon Feb 09, 2009 1:57 pm

Re: NEED HELP

Post by manRay »

I actually was able to fix it on my own, after reading about 30 posts and 10 tutorials...lol
I am now working on a file uploader....So far, it is able to upload files to a folder on the site, but I doubt that is the most economical way of going about that. The code is below.
FORM
<form action="/php/upload.php" enctype="multipart/form-data" method="post">
<p>File Name:<br /> <input type="text" name="filename" size="30" /> </p>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
<p>Select a file:<br /> <input type="file" name="datafile" size="40" /> </p>
<input type="submit" value="Upload" />
</form>

UPLOAD.PHP
<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['datafile']['name']);

if(move_uploaded_file($_FILES['datafile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['datafile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}


?>
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: NEED HELP

Post by Benjamin »

You still have not edited your first post containing code to use the tags. Do you not understand how to do this?
Post Reply