I have a login script that use to work, but for some reason it does not work now!
You guys can test it here: http://lamezz.com/_NEW/login.php
USER: test
PASS: test
it uses a script that is in the bin folder, and the members pages has a PHP code in it to tell the script to give access to the user.
I will reveal any script you guys wanna see!
Pleas Help!
12 2347 Atli 5,058
Recognized Expert Expert
Hi Lamez. Welcome to The Scripts!
This looks like a problem with your login script. I would guess your user information is not being stored the way you want it to.
Could you post the login script?, and maybe the part of the script in the Members area that checks if you are logged in?
pbmods 5,821
Recognized Expert Expert
Heya, lamez.
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Make sure session_start() is at the top of each page.
Sorry guys, I am new and I need some help!
here is my login form - <form action="_bin_/login.php" method="post" onSubmit="return validate()">
-
<p class="center">
-
Username: <input type="text" name="username" size="20">
-
<br />
-
<br />
-
Password: <input type="password" name="password" size="20">
-
<br />
-
</p>
-
<p class="center">
-
<input type="submit" value="Log In">
-
<br />
-
<br />
-
<a href="?id=forgot_password">Forgot Password?</a>
-
</p>
-
</form>
Here is my login script -
<?php
-
ob_start(); // <-- move to top
-
?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<link rel="stylesheet" type="text/css" href="../style/default.css"/>
-
<title>Lamez`s Corner</title>
-
</head>
-
<body>
-
-
<div class="logo"><img src="../style/img/logo.gif" alt="Lamez's Corner" /></div>
-
-
-
<div class="menu">
-
<ul>
-
<li class="nonselected"><a href="../index.php">Home</a></li>
-
<li class="nonselected"><a href="../_login/_members/members.php">Members</a></li>
-
<li class="selected"><a href="../login.php">Login</a></li>
-
<li class="nonselected"><a href="../register.php">Register</a></li>
-
<li class="nonselected"><a href="../about_me/about.php">About Me</a>
-
</ul>
-
</div>
-
-
<div class="box">
-
<h4>Logging In</h4>
-
<p class="center">
-
<?php
-
ob_start();
-
-
include("config.php");
-
-
// connect to the mysql server
-
$link = mysql_connect($server, $db_user, $db_pass)
-
or die ("Could not connect to mysql because ".mysql_error());
-
-
// select the database
-
mysql_select_db($database)
-
or die ("Could not select database because ".mysql_error());
-
-
$match = "select id from $table where username = '".$_POST['username']."'
-
and password = '".$_POST['password']."';";
-
-
$qry = mysql_query($match)
-
or die ("Could not match data because ".mysql_error());
-
$num_rows = mysql_num_rows($qry);
-
-
if ($num_rows <= 0) {
-
echo "Invalid Username or Password<br>";
-
echo "<br />";
-
echo "<a href=../login.php>Try again</a>";
-
echo "</p>";
-
exit;
-
-
} else {
-
-
setcookie("loggedin", "".$_POST['username']."", time()+(3600 * 24));
-
-
echo "<p class=logging>";
-
echo "Welcome <strong>".$_POST['username']."</strong><br />";
-
echo "</p>";
-
-
-
}
-
ob_end_flush();
-
?>
-
<br />
-
<center><img src="../style/img/loading.gif" alt="Loading Bar" /></center>
-
<meta http-equiv="Refresh" content="5; URL=../_login/_members/members.php">
-
</p>
-
</div>
-
<div class="footer">
-
<p> Site Template & Original Site Content
-
<br />© 2007-2008 <a href="mailto:lamez@lamezz.com">James Little</a>
-
</p>
-
</div>
-
-
<div class="spacer">
-
</div>
-
-
</body>
-
</html>
Here is the PHP block in the members page - <?php
-
$username = $_COOKIE['loggedin'];
-
if (!isset($_COOKIE['loggedin'])) die("Please login to view this page.");
-
echo "Welcome $username";
-
?>
-Thanks Guys
I think there is a discrepency in your cookie. Try var dumping your cookie on the member page and check the variables. Also, server side sessions are much more elegant than cookies especially when dealing with logging in. Theoretically, someone could make their own cookie on their machine to mimic your cookie and log themselves in.
I am new to PHP, could you explain more, thanks!
[PHP]var_dump()[/PHP] is a valuable function which prints any data stored in a variable to the page where it is called;
example: -
$array[0] = 1;
-
$array[1] = 2;
-
-
var_dump($array);
-
This will output something like
array(2) { [0]=> int(1) [1]=> int(2) }
you can call [PHP]var_dump()[/PHP] on any variable such as cookie data.
Sessions are a whole other chapter...
Atli 5,058
Recognized Expert Expert
I agree with karlectomy. You should use Sessions instead of cookies. It would be a lot more secure.
Check out this article I wrote about Sessions if you want to try it. Should show you exactly what you need.
Check out this article I wrote about Sessions if you want to try it.
Atli,
Great article, btw. Nice, simple examples. I usually pass the session ID as a GET var, I wasn't aware you could pass as POST.
Could you fill me in on how you POST your SID?
also, is there a way to encode the SID In a URL Parameter?
Atli 5,058
Recognized Expert Expert
Atli,
Great article, btw. Nice, simple examples. I usually pass the session ID as a GET var, I wasn't aware you could pass as POST.
Could you fill me in on how you POST your SID?
also, is there a way to encode the SID In a URL Parameter?
I'm not sure what you mean. How do you pass the session ID?
PHP will try to pass the session ID automatically. By default it will try to save it as a cookie, if that fails it tries to send it via POST. If that is not possible it will try to pass it in the URL, through GET.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: bryce21 |
last post by:
I'm trying to write a script that logs into Yahoo Fantasy Football.
Once logged in, I'll be able to grab stats and various other pieces of
info about our league. The problem I'm having deals with actually
logging in programatically.
I've been using Snoopy to help with the user agent side of things and
it seems to work well. I can successfully put together a valid yahoo
login URL based on username/password/challenge. It looks like the...
|
by: Paul M. |
last post by:
Hi,
we have 2 www systems one which we wrote ourselves the other is a parent
company one over which we have no control. The 2nd system involves the user
having to enter a username & password in a login screen. Is there any way of
calling the 2nd systems login page and having the username & password be
inserted automatically? This auto passing in of information might also be
applied to optins selection so instead of manually clicking on...
|
by: GreenBayFan |
last post by:
Hello, I am a computer science major. I have had HTML and Java, but not any
JavaScript. I know they are similar, but there seem to be a lot of functions
and methods I am not familiar with. Plus I don't have a good understanding
of what Java can do within the web environment. (My Java classes
concentrated on console based applications.)
What I want is a simple Java Login box for "Apartment Number" that takes
that value and assigns it to a...
|
by: nfhm2k |
last post by:
I've been trying to find a solution to this for quite some time now...
I even took a look at existing scripts...
Including this one...
http://groups.google.co.uk/group/comp.lang.php/browse_thread/thread/2e052386da903425/b03ec83ac55273a2?lnk=st&q=&rnum=1#b03ec83ac55273a2
Everyone on that post seems to say its to do with the cookie's, yet if
infact they had tried this script they would have found that even with
the cookies enabled this...
|
by: pj |
last post by:
I'm trying to redirect users to another page after they Authenticate
with the ASP.NET login controls. The user is able to login, but I
can't get the response.redirect to work. Can anyone help?
My code is below.
Thanks,
pj
mcdba, mcp
| |
by: dylanhughes |
last post by:
I'm looking for an example of a login system that has multiple fields
(2 to be exact) + password. e.g username, company name and password,
the user, company and password are checked against a mysql database. I
have it working with just the username field but I'm confused on how
to go about adding another field. I'm pretty new to PHP so don't beat
me up too much for this example code, I borrowed and hacked it
together in a very short period...
|
by: nathj |
last post by:
Hi,
I have a quick favour to ask - would someone please check over this concept for me?
Basically I need to generate a login script and while time is on my side I want to invest in writing my own so that I fully understand and can fully control what is going on.
When a visitor applies for membership they assign themselves a password that is hashed and stored in the database. I do not have, nor do I want a remember-me (stay logged in)...
|
by: harsh9892991141 |
last post by:
every time enter my login id and password in my index page it shows me the error 404
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
127.0.0.1
|
by: adweaver |
last post by:
Hello All,
I'm new to the world of php. I've just had a site designed for me by a company, and I'm now trying to manage and grow it, so it will suit my needs.
The site was built in a folder called mysite.com/test. I coppied this folder a number of times, so I now have mysite.com/test2, mysite.com/test3 etc. Each folder acts as its own landing page.
they setup an interface where we can control the upsells presented to the customer;...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |