Read Latest Entries..: (Post #11) by dedesigns on Oct 2 2006, 05:50 AM. (Line Breaks Removed)
try something like this..CODE<?session_start();if (isset($_SESSION['loginname'])){you are already logged in}else if ($_POST[submit]){check if the password and username are valid and if so, you are logged in}else{print the form to login}?>Hope this work.. if not then message me again..dedesigns
Notice from ... read more.
I am using the following code as a login page. I try to start by checking if a session already exists so that people don't have to login each time. The problem is that it is just being ignored. How do I check if a session is already set?
CODE
if (isset($_SESSION['loginname'])) { print('you were already logged in'); } else { if (submit) { list($users,$passwords,$accounttypes)=GetCurrentUsers($user,$password,$accounttype); $nologin=1; for ($i=0;$i<sizeof($users);$i++) { if (($users[$i]==$loginname) and ($passwords[$i]==crypt($loginpassword,$passwords[$i]))) { $nologin=0; } } } if ($nologin==0) { session_start(); $_SESSION['loginname']=$loginname; print('you are logged in'); } else { print('<form>'); print('<br />Username: <input type="text" name="loginname" size="20">'); print('<br />Password: <input type="password" name="loginpassword" size="20">'); print('<br /><input type="submit" name="submit" value="login">'); print('</form>'); } }
Hum it all seems a little complicated to me so ill show the code for my login script ive used before and see if it is of any use to you.
this is as i remember it anyway...
CODE
<? SESSION_start();
if($_SESSION[loggedin] == "1"){ // any code to be executed when logged in. else{ //anything to do if they arent logged in, usually an error message or login page redirection. };
to check sessions i used a seperate php file that was included on every login protected page including the login page, the session script set a variable which i used in the login page something like
CODE
if($loggedin == "1"){ echo "you are logged in already"; } else { echo <HTML> login page data </HTML>"; };
it worked for me!
ive only used sessions once so its fairly basic but i tried basic attempts at bypassing it and i couldnt. However there was an issues with using session_start(); to continue a session which you should check out on www.phpsec.org i cant remember it so its probably best you read it, its in the articles section if i remember rightly.
I am not doing much different. My script can be summarized as:
if (isset($_SESSION['loginname'])) { you are already logged in } else { if (submit) { check if the password and username are valid and if so, you are logged in } else { print the form to login } }
The problem is that the first line "if (isset($_SESSION['loginname'])" that is supposed to check if there is a login name in the current session is always returning false, even if there is a session with a loginname in there.
I have googled this issue a little and it seems that I should start my entire script with "session_start()". The problem is, though, that it regenerates a NEW session, instead of using the old one.
Once again, my script is not that difficult... but even if it is, I would like to understand what I am doing wrong as that is the only and best way to learn.
I have googled this issue a little and it seems that I should start my entire script with "session_start()". The problem is, though, that it regenerates a NEW session, instead of using the old one.
~M
Yes for the session global variables to be avaliable you need to use session_start() im not sure if it was the way my script was set out that allowed it to keep track of sessions basically it is this:
CODE
include("check.php"); if($_SESSION['loggedin'] == "1"){ //if user is logged in make html content } else { //give an error }
check .php was the only page where i used session_start so perhaps because it was controlled on one page it kept track of things. Otherwise it could be a problem with the installation you as using as youmight need to fiddle with directories to allow sessions to be stored and/or make sure cookies are enabled. I dont see a problem with the script myself as i thought that session_start simply brought back the global array $_SESSION[' '] for use and to overwrite a session you had to destroy it first. Check that you have a "tmp" or "temp" or similar directory in your server root, if using a hosting company it shouldnt be a problem but if using a development environment it might need tampering as if this directory exsists sessions cant be saved on the web server and this could cause problems if the ini file says that all sessions must be saved on the server.
but other than that im afraid i dont know what to say, like i said ive not had much experience with sessions Good luck though
Well session_start() must be the first thing you must call before any headers are outputed.If headers are first called before the session_start() function is called it would result in an E_WARNING level error.
Your present script does not contain this function in the beginning resulting in this false return. Also I would like to add that Sessions are stored on the Server itself in a file or if you want in a Database like MySQL and the client is recognised by means of a SESSION ID that is transmitted through either the cookies on the Client side or through the URL using the GET Method. So if the user has no COOKIES Enbled it would again result in the failure of your script. Well this is just part of all the Security concerns and when sessions could fail.
My script now starts with "session_start()". The problem is, that each time I reload the page, it makes a new session instead of using the information of the old session. I have php and mysql installed locally on my computer and there is a session file created in my session directory. The problem is, that its excistence is ignored. Also, accepting cookies is enabled.
You have to consider checking if there are old sessions stored if no old sessions are stored then it is time to create a new session. IMHO, your script generates a new session everytime it loads.
if (isset($_SESSION['loginname'])) { you are already logged in } else if ($_POST[submit]) { check if the password and username are valid and if so, you are logged in } else { print the form to login }
?>
Hope this work.. if not then message me again..
dedesigns
Notice from BuffaloHELP:
Use the proper bbcode and refrain from signing off with every post you make.
I've been looking all over the net for a PHP script which can provide an interface to browse a
downloads database. The database could be powered by MySQL. If you know a script like this, please
post it here. Thanks in advance, Ironchicken....
This script was found on the net http://tips-scripts.com/?tip=watermark#tip B&T's Tips &
Scripts site. Just in case the site may not show, I will include the code here: List of things
needed: 1. your image in any format 2. watermark image--in gif format with transparent background 3.
script below with name (i.e. watermark.php) CODE <?php // this script creates a watermarked
image from an image file - can be a .jpg .gif or .png file // where watermark.gif is a mostly
transparent gif image with the watermark - goes in the same directory as this script // ...
Ok so i'm still working on the forum software i posted about a while back, but I have no idea
how to do this. I want to make a view new post script, as this is one of the main things that my
forum software dose not have that all other forums have. so does any body have an idea on how i
would do this? Thanks....
Yes, yes. I have another script that I have written and I am distributing. I am not entirely sure if
this works. I have not tested it yet, but I will later and post back with a demo and fix it up.
Current script: CODE <?php //Save this as something like htmltest.php function
CheckForm() { $html_unsafe=$_POST['code']; //Gives us our user
input $html_safe=str_replace("<?php"," ",$html_unsafe);
//Starts security measures $html_safe=str_replace("?>","
",$html_sa...
I'm not sure if this is the right place to post this but I really need help in installing the
dolphin community script. I have absolutely no previous experience of scripts or programming. I
would really appreciate if someone could walk me through it step-by-step, or even do it for me by
logging into my cpanel. I have tried to install it my self but I'm a little confused. I'm
sure it won't take very long at all for someone who has done this before....
Hi. I've just created a php script. The main object of the script is to delete some old files
and replace it with a new file with some new content, effectively moving the contents from one file
to another. These are the first 50 lines of the file: /* Calculate For The "A" Group - The
Latest Games ID */ $a_B = 002; while(file_exists("a_" . $a_B . ".dat")) {
$a_B++; } $new_page_contents = " " . $_POST . " " . $_POST . "
include \"/home/cmatcme/public_html/footer.php\"; ?> "; $a_stream = fopen(&...
Hi everybody sorry if i posting here , i know I want design free PHP script and i dont know
webmasters what kind of scripts want i think its better to aks here becuase trap17 is very nice
webmasters forum So , Plz post here what kind of script with details you need ! sorry may en
is not very well for example you need "upload center" : write "upload center" with upload center
options ( like Ajax , Fast , multi lan and ... ) with this post we can give script details and
webmasters idea /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile....
Hi, when running a PHP script I keep getting the error: QUOTE Notice: Undefined variable: bret
in c:\program files\easyphp1-8\home\poll.php on line 294 Notice: Undefined
variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294 (And,
yes, I get it twice). The code related to the variable is as follows: CODE function
LogString($string,$type) { $t_log = "\n";
$t_log .=
$this->globaldata->server_vars['REMOTE_ADDR']."...
Hi I am trying to make a script so that i can insert songs into a playlist, but i need a script in
which it opens the playlist file and removes the closing tag at the end, so before i can add more
entrys. e.g CODE <atx> <entry>Location 5</entry> <entry>Location
4</entry> <entry>Location 3</entry> <entry>Location
2</entry> <entry>Location 1</entry> <atx> But to add more entrys
i would have to get rid of the atx, then use the fputs to place the new entry into the file. ...
Any free auction script suggested? I want it to be as many practical functions as possible, yet
easy to manage. And more importantly, it is free! Appreciate your kind suggestions!...
I am not new to programming. I want to create a form to add some values into my tables, the code
are all working. But I am not sure what is the URL to connect to my site's database. All along,
I have been testing through MAMP, which provides a local copy of mySQL. Can anyone lend me a hand?
My site's URL is http://limetouch.com/ ...
Ok, what I am trying to do is this. Re-direct a domain name called: avalon.asn.au to
preschool.stmarksavalon.org.au I have created a script that will re-direct within the a folder.
However, the avalon.asn.au and stmarksavalon.org.au are PARKED Domains. Any ideas on how to create
this PHP Redirect Script please?...
Hello, I'm looking for a download script for sound files (e.g. mp3, avi, wma, and other ones).
i have found a few download scripts but they would not work for sound files for some reason. also
this will not be used for allowing downloading of illegal or riped music, what i will be using this
script for is i'm making a site for my church and the pastor wants to be able to recored the
services and then have me upload them to the site so that the church members can download them for
what ever reason. If some one could tell me how to make one or could show me a plac...
Hello, everyone. Anyone knows where I can get a library script that acts like CMS script software,
you can add books or delete them. I want to build virtual online library which can be accessible to
everyone. Or just give me some advices how to make it build. I'm a novice in programming....
Hello, i'm wanting to start making my own forum software but i dont know where to start or what
i need to know in order to do this. I know i will need php and mysql but what else, and could some
one point me to a good site were i could learn php and mysql. Thanks ...
I plan on making a script for basic voting between different options, and I'd like to know what
PHP coding I would require. Basically, each choice will be as simple as this: CODE <form
method="post" action="process.php"> Best falsetto?<br><br>
<input type="radio" name="1"> Person A<br> <input
type="radio" name="2"> Person B<br> <input type="submit"
value="Submit"> </form> What PHP would be used to basically add 1 value to a...
When we login, we got a session. But at the same time when we still login, another one could login
at our account. So, can we restrict only one user could login at one account? So if another wants
to log into the same account, he must wait until the one logs out. Thanks in advance....
here is a very old version of my wap chat script, its not very advanced but has privates, smileys
etc. I will post some further versions (with owner, admin, mod status and profiles) when i have time
to write the readme/install instructions for them. You will find instructions inside the zip. If you
have any problems post here but i know it don't work on all servers for some reason but it does
work on the trap server so will be cool ok /tongue.gif" style="vertical-align:middle" emoid=":P"
border="0" alt="tongue.gif" /> ...
For some reason my random string script is not working. I got a fatal error when I tried it under
XAMPP. I do not know why. It looks syntatically correct. Could someone help me? Here is the script:
(Warning its over 100 lines long) //This PHP script will generate a random array and turn it into
a string consisting of 0-9 and A-Z. // This is the first developmental version. //Create 10 item
array for string $string = array(0,0,0,0,0,0,0,0,0,0); //Create function to replace 10-36 with
A-Z function conToStr() { for ($a = 0;$a switch($string ) { ...
hi i'm not that great at php so i'm not to sure if this will work or not. but what i want to
do is be able to use ?p=staff or what ever page name, with out the php extion, and i would like to
no if this simple script i made would work. the code is: CODE <?php $p =
$_GET['p']; if ( !empty($p) &&
file_exists('./' . $p . '.php') && stristr( $p, '.'
) == False ) { // pages = directory where you store your pages $file = './'
. $p . '...
Hello, I've one registration page where the users fills in their information, is it possible to
trasnfer the things the fill in on the registration page to another script that does someting and
returnes something to the first page like true/false and then the registration gives an error
messange if the other php script returned false? Something like the script "activates" another
script that does something and returnes the result back to the original script. Best Regards ...
long explaination: hey, I'm building a user profile site right now. And, I kinda know how to
make a online/offline detector, but not totally sure. I know I can make a mysql database to track
them, but how does it entrer the information? I could easily put in a field where when they login it
sets them to online, but if they don't sign out, and just exit the browser, how can I tell.
short: I want someone to tell me how to make a online/offline status detector, like they have here
on trap17. I'd be thrilled if you can post to this, thanks, arcticsnpr...
You can test it out for yourself at http://sonesay.trap17.com/application.php I've been
working on this page locally and it seems to be working fine but when I upload it to my trap17
account the post variables dont get saved properly. Fill in some fields and submit it, the form
will come up as a empty field yet when you resubmit it without any modifications and the data you
entered in orginally will now magically appear, resubmit it again and it will be gone. This is
really annoying as I have no clue why it would be doing this when it seems to work fine locally....
Okay, I am trying to password one page of my website. I need confirmation if this is a safe code or
not. The whole code is on the page I'm protecting. CODE <?php
include('header.php') ?> <?php // Define your username and password
$username = "THE_USERNAME"; $password = "THE_PASSWORD"; if
($_POST['txtUsername'] != $username ||
$_POST['txtPassword'] != $password) { ?>
<h1>Login</h1> <form name="form" method=&...
A search engine is provided to facilitate the user with undemanding and clear-cut search options.
The search facility includes simple search, search by title, search by word/phrase, ect… Thus, the
user is at a safe distance from the risk of selecting files/folders ambiguously. In addition, a
history of recent searches can be preserved for future perusal. Now
day’s visitors have a large option for his needs on internet and so visitors are not vesting their
time by following the dead links on your site. So a search engine is essential for your...
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE
forum, Create your own topics, Ask Questions, track topics, setup
subscriptions & notifications and Get a Free Website w/ Email and FTP.