473,800 Members | 3,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

allowing users to log into my website

I'm trying to create the necessary framework to allow users to log
into my website. I have already created the backend using a MySQL
database. The part that I'm hung up on is being able to pass the
username from one page to the next. I've been reading about sessions,
and I can get them to work if I embed the SID into the URL, but I
really dislike that method. I've read that cookies can be used
instead, but I cannot get these to work. I've been changing values
like session.use_onl y_cookies = 1, session.save_ha ndler = files,
session.save_pa th = "C:\Temp", etc. but none of them are helping. I
can see the files being created in C:\Temp, and they are populated
with the username that I'm assigning to $_SESSION['username'], but
it's not available on the next page. I'm running Apache 2 and PHP
5.2.5 on a Windows XP SP2 Home machine. Any ideas?

<?php

session_start() ;

include("UserFu nctions.php");

$mode = "";
$username = "";
$password = "";

if (!isset($_POST['mode']))
{
unset($mode);
}
else
{
echo "setting mode to ".$_POST['mode']."<br>\n";
$mode = $_POST['mode'];
}

if (!isset($_POST['username']))
{
unset($username );
}
else
{
//echo "setting username to ".$_POST['username']."<br>\n";
$username = $_POST['username'];
}

if (!isset($_POST['password']))
{
unset($password );
}
else
{
//echo "setting password to ".$_POST['password']."<br>\n";
$password = $_POST['password'];
}

if (!isset($mode))
{
if (!isset($_SESSI ON['username']))
{
echo "session user = ".$_SESSION['username']."<br>\n";
echo "<FORM name=login method=post action='login2. php?
mode=confirm'>" ;
echo "<INPUT type=hidden name=mode value=confirm>" ;
echo "<TABLE align=center>";
echo "<TR>";
echo "<TD>Userna me:</TD>";
echo "<TD><INPUT type=text name=username></TD>";
echo "</TR>";
echo "<TR>";
echo "<TD>Passwo rd:</TD>";
echo "<TD><INPUT type=password name=password></TD>";
echo "</TR>";
echo "<TR>";
echo "<TD colspan=2 align=center><I NPUT type=submit value='Log In'></
TD>";
echo "</TR>";
echo "</TABLE>";
echo "</FORM>";
}
else
{
$firstname = getFirstName($_ SESSION['username']);
echo "Welcome, ".$firstname.". ";
}
}
else if (strcmp($mode,' confirm') == 0)
{
if (!isset($userna me) || !isset($passwor d) || strcmp($usernam e,"") ==
0 || strcmp($passwor d,"") == 0)
{
echo "Please provide a username and password.<br>\n ";
}
else
{
if (!confirmLogin( $username, $password))
{
echo "Username and/or password is invalid.<br>\n" ;
}
else
{
//openSession($us ername);
$_SESSION['username'] = $username;
//echo "session username = ".$_SESSION['username']."<br>\n";
//echo "<a href='login2.ph p'>login2.php</a><br>\n";
//header("Locatio n: main.php");
header("Locatio n: login2.php");
}
}
}

?>
Dec 22 '07 #1
1 1288
halamazoo wrote:
I'm trying to create the necessary framework to allow users to log
into my website. I have already created the backend using a MySQL
database. The part that I'm hung up on is being able to pass the
username from one page to the next. I've been reading about sessions,
and I can get them to work if I embed the SID into the URL, but I
really dislike that method. I've read that cookies can be used
instead, but I cannot get these to work. I've been changing values
like session.use_onl y_cookies = 1, session.save_ha ndler = files,
session.save_pa th = "C:\Temp", etc. but none of them are helping. I
can see the files being created in C:\Temp, and they are populated
with the username that I'm assigning to $_SESSION['username'], but
it's not available on the next page. I'm running Apache 2 and PHP
5.2.5 on a Windows XP SP2 Home machine. Any ideas?

First thing - edit your php.ini file to enable error reporting for all
errors and display the errors:

error_reporting =E_ALL
display_errors= on

(leave the second one off in a production environment).

See what errors you get.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===

Dec 28 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2348
by: Terry Murray | last post by:
Hi Everybody, I have been given the task of creating an online coupon system. The only real challenge that I can identify at this point is allowing only one coupon to be printed rather than several times. Because printing is done on the client side, I thought that it would make sense to post this to newsgroups that cater to the JavaScript folk. Can anyone out there point me to how I would enforce this, that is, allowing only one...
1
1741
by: HorseGeek | last post by:
I have three servers: Server1, Server2, and Server3. There is a login cookie does not expire for SOME users on Server2. Ironically, the login cookie expires correctly for ALL users on the Server1 and Server3 websites. This seems to imply a problem with the user's browser settings ... except the users that have consistent problems with the Server2 are able to read the logon cookie and other cookies which control navigation to the...
2
3480
by: AVB | last post by:
Is there any other way to write files to a directory than allowing the IUSR write access. We have a website that will be writing XML files and Label files to a directory outside of our website directory but I am hesitant to give the generic IUSR account write access to anything and wondered if we could asign a different account or if there was some sort of ASP script we could use. These files will be created based on a received XML string...
2
13363
by: Dave Smithz | last post by:
Hello there, Summary: How far can you go with SQL Select queries using like clauses with wildcard characters. Can you apply anything like regular expressions? Full details: On a Intranet website, I request a code from a user which is then compared with a code in an ADO access database.
7
2922
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the database into classes, which are used throughout the application. I have made class collections which, upon reading from the DB, create an instance of the class and store the DB values in there temporarily. My problem is that if user1 looks at...
3
2091
by: Gary T via AccessMonster.com | last post by:
I have a couple of lulus here but I'll address the other one in "Queries". This one pertains to allowing users with read-only access to use the database whilst a person with admin access is using it. The way it stands right now, if an admin user is in it the r/o user gets a prompt that the DB is locked. Bear in mind, I am only allowed to use system security, NOT Access security. Any takers
2
5990
by: Jim in Arizona | last post by:
My goal, somehow, is to populate a dropdownlist with all the user names in active directory. I don't even know where to begin, really. I added a reference to System.DirectoryServices so I could use the System.DirectoryServices.ActiveDirectory namespace. I don't even know if this is the right way to go as I can't seem to find anything in that namespace that would help me query active directory for names. I can't use an LDAP query...
3
1454
by: Neil Steventon | last post by:
Hi, Im after some advise on how to go about this problem. I have a master page with nice header and side bar setup. I then have various aspx pages that use this master page. I want one of the aspx pages to be editable by a user. This saves me having to doing any of the changes. Should I give them access to a public folder for an HTML page that I then include in the website. What are the best ways to tackle this kind of
2
2481
by: HSD | last post by:
database not allowing multiusers -------------------------------------------------------------------------------- Background An ACCESS database containing two tables and three forms has been installed on the network drive. Using the Tools Menu (Security Sub Menu), five users have been added to the USERS group in the database. The Users group has been assigned OPEN/RUN permission for the database object. The DEFAULT RECORD LOCKING...
0
9694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10256
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6824
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.