Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 12-14-2006, 03:40 PM   #11
Fully Optimized
 
^Mike^'s Avatar
 
Join Date: Oct 2005
Posts: 2,958
Send a message via ICQ to ^Mike^ Send a message via AIM to ^Mike^ Send a message via MSN to ^Mike^ Send a message via Yahoo to ^Mike^
Default Re: Creating a new login prompt for website

Quote:
Originally Posted by root
ok... in that case this should work for you...

Code:
<?php

ob_start();

$user_name = "ALEC";
$pass_word = "password";

$username = @$_POST['username'];
$password = @$_POST['password'];

if(($user_name == $username)&&($pass_word == $password))
{
header('Location: index_1.html');
}
else
{
echo '
<form method="POST">
<input type="text" name="username"><br />
<input type="password" name="password"><br />
<input type="submit">
</form>
';
}
?>
you can obviously change the username and password to whatever you like.
ok thanks! i'll try it out
__________________

^Mike^ is offline   Reply With Quote
Old 12-14-2006, 09:23 PM   #12
Solid State Member
 
Dyamito's Avatar
 
Join Date: Dec 2006
Posts: 17
Default Re: Creating a new login prompt for website

Although with that method, anyone can just go to supposed index_1.html and have total access. Whereas, you could do something like this, roots script slightly modified:
Code:
<?php
session_start();

$user_name = "ALEC";
$pass_word = "password";

$username = @$_POST['username'];
$password = @$_POST['password'];

if(($user_name == $username)&&($pass_word == $password))
{
$_SESSION['Verified'] = "Yes";
header('Location: index_1.html');
}
else
{
echo '
<form method="POST">
<input type="text" name="username"><br />
<input type="password" name="password"><br />
<input type="submit">
</form>
';
}
?>
And on index_1.html or whereever it is redirecting (make a php page):
Include this:
Code:
<?php
session_start();
if ( (!isset($_SESSION['Verified'])) )
	{
		exit(); // if not logged in, show a blank page
	} else {
	
	// your sites code here....
	
	}
?>
__________________

Dyamito is offline   Reply With Quote
Old 12-14-2006, 09:57 PM   #13
Fully Optimized
 
^Mike^'s Avatar
 
Join Date: Oct 2005
Posts: 2,958
Send a message via ICQ to ^Mike^ Send a message via AIM to ^Mike^ Send a message via MSN to ^Mike^ Send a message via Yahoo to ^Mike^
Default Re: Creating a new login prompt for website

Quote:
Originally Posted by Dyamito
Although with that method, anyone can just go to supposed index_1.html and have total access. Whereas, you could do something like this, roots script slightly modified:
Code:
<?php
session_start();

$user_name = "ALEC";
$pass_word = "password";

$username = @$_POST['username'];
$password = @$_POST['password'];

if(($user_name == $username)&&($pass_word == $password))
{
$_SESSION['Verified'] = "Yes";
header('Location: index_1.html');
}
else
{
echo '
<form method="POST">
<input type="text" name="username"><br />
<input type="password" name="password"><br />
<input type="submit">
</form>
';
}
?>
And on index_1.html or whereever it is redirecting (make a php page):
Include this:
Code:
<?php
session_start();
if ( (!isset($_SESSION['Verified'])) )
	{
		exit(); // if not logged in, show a blank page
	} else {
	
	// your sites code here....
	
	}
?>
ok thanks, i'm going to try this tommorrow. +1
^Mike^ is offline   Reply With Quote
Old 12-15-2006, 06:00 AM   #14
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,003
Default Re: Creating a new login prompt for website

Quote:
I'm not trolling for members root. For all you know I could have been giving him Buzz's e-mail address
stop trying to be smart and consider this for one moment.

Giving someone buzz's email address is of absolutly no help to this forum what-so-ever...

the whole point of a forum is that people ask questions and other people answer in the thread...

that way when the next person comes along and searches for a login script, they can find one, not get presented with a dead end thread that was someone who was supposed to be a great member of the forums just leaving threads dead ended with no answer to the question.

I think that you miss the point that the forums are not only meant to help the person asking the question, but are also open to help all and sundry who want answers.

for Christs sake you admin your own forum, surely you have some awareness of what consitutes a useful post and what doesn't


-------------------------
as for the sessions.

yes, I had thought about sessions, but Mike said he wasn't bothered about making it too secure.

Dyamito, you cut off the ob_start,
i assume that this PHP file will be included somewhere half way down a page, so he'll need that to buffer the outpu headers, else the headers will be sent and can't be changed to add session information...

Do you have output buffering turned on for your test server...? (wouldn't show as a problem if you did..)
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 12-15-2006, 06:54 AM   #15
Solid State Member
 
Dyamito's Avatar
 
Join Date: Dec 2006
Posts: 17
Default Re: Creating a new login prompt for website

Even if you weren't being secure, that's really basics, anyone could get there. Although, I haven't really been programming in a while so I even had trouble with that script, so if I make a mistake, it seems root is able to correct me.
Dyamito is offline   Reply With Quote
Old 12-21-2006, 05:46 PM   #16
In Runtime
 
jamieoliver22's Avatar
 
Join Date: Apr 2004
Posts: 245
Default Re: Creating a new login prompt for website

If you want, you could always password protect a directory on the server (as long as its a *nix/apache server).
__________________
Desktop: AMD Athlon XP 2000+ - 1.6ghz | MSI KT4-Ultra Motherboard |ATI Radeon Powercolor x850 XT 256mb DDR3 | 400gb HDD space |1gb PC2700 DDR SDRAM.
---
Laptop: AMD Sempron 3200+ - 1.6ghz | ATI Radeon Xpress 1100 - 128mb | 100gb PATA HDD | 1gb DDR2 RAM.
jamieoliver22 is offline   Reply With Quote
Old 12-21-2006, 07:23 PM   #17
Fully Optimized
 
^Mike^'s Avatar
 
Join Date: Oct 2005
Posts: 2,958
Send a message via ICQ to ^Mike^ Send a message via AIM to ^Mike^ Send a message via MSN to ^Mike^ Send a message via Yahoo to ^Mike^
Default Re: Creating a new login prompt for website

well i got it fixed a few days ago making a php login so thanks everyone!
^Mike^ is offline   Reply With Quote
Old 12-21-2006, 09:07 PM   #18
Golden Master
 
joxley1990's Avatar
 
Join Date: Oct 2005
Posts: 7,846
Send a message via AIM to joxley1990 Send a message via MSN to joxley1990
Default Re: Creating a new login prompt for website

Well done with that, how you work it out?
__________________

joxley1990 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 08:25 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0