It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

VERY SIMPLE (but not for me) Please Help!

VERY SIMPLE (but not for me) Please Help!

Postby Immortalis on Fri Sep 29, 2006 5:54 pm

I'm desinging my website and need a very simple script.
I know nothing about scripting, only the basics of web design so would really appreciate any help with this.

Basically, I want a login form that lets you insert the username and password.

when you click the Submit button, I want it to open a webpage address like so...

http://username:password@www.whaterverurl.com
(this link doesn't work.. it's just my example)

I "KNOW" this is a really simple scripting task. Thanks in advanced.
Immortalis
 
Posts: 3
Joined: Fri Sep 29, 2006 5:50 pm

Postby Immortalis on Fri Sep 29, 2006 7:06 pm

Hmm.. noone knows how to do this? =(
Immortalis
 
Posts: 3
Joined: Fri Sep 29, 2006 5:50 pm

Postby nighthawk on Fri Sep 29, 2006 8:20 pm

[php]
<?php
require('../function.php');
session_start();

if (isset($_POST['username']) && isset($_POST['password']))
{
$userid=$_POST['username'];
$password=sha1($_POST['password']);

mysql_connect('localhost',$datname,$datpass);
mysql_select_db($db);

$query='select * from admin '."where username='$userid'"." and password='$password'";

$result=mysql_query($query);
if(mysql_num_rows($result)>0)
{
$_SESSION['admin']=$userid;
}
mysql_close();
}
html_head();

if(isset($_SESSION['admin']))
{
?>
html that you will show if user is logged in
<?
}
else{
echo'<br />You are not logged in';
}
?>[/php]

I put database username, password and name of db in separate file called function.php so I could access it from multiple scipt, but you put those values instead of $datname, $datpass and $db inside sigle quote ( 'username',...). You also need mysql database with usernames and passwords.
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ

Postby Immortalis on Fri Sep 29, 2006 9:09 pm

I was hoping to avoid the database part.

Lemme see if i can make this a bit clearer.

When I try to go to a restricted page, a window pops up asking for username and password.

The database already exists for acceptable usernames and passwords.

What I want to do, is basically create a more professional looking login screen so when they login, they can access it without getting the popup, which is where the www."username":"password"@wherever.com would come in, logging them in and bypasing the popup.

The database that already exists, I don't know what its called and don't have direct access to it, but it should be irrelevant, if the user/pass is accepted, it should let me view the page, if it's not, another page saying access denied would appear.

For what I want, I think it should be a simple script that shouldn't involve any php, or db access or anything.

(I could be wrong though.. I don't know much about htis stuff)
Immortalis
 
Posts: 3
Joined: Fri Sep 29, 2006 5:50 pm

Postby nighthawk on Sat Sep 30, 2006 7:32 pm

So you are using .htaccess?

You could do this without database, simply store usernames and (encrypted) passwords in php file. Downside - not very safe, new users cannot be automaticaly added, too much work if you have a lot of members.

Databases are not that hard to deal with
The Zeitgeist Movement
User avatar
nighthawk
250+ Club
 
Posts: 420
Joined: Sun Jun 11, 2006 1:53 pm
Location: SFRJ

Postby mwa103 on Mon Oct 02, 2006 7:26 pm

I think, if I understand correctly, all that is needed is a redirect that uses submitted form information. Correct me if I'm wrong, but the way I understand it:
There is a database setup and the page is set up already so that, after loging in, the page displayed has the address of http://username:password@www.whaterverurl.com

This could easily be done with a bit of php or Javascript. All I know is the php, but hopefully someone with Javascript knowlege can tell you how to do it using that instead.

What I know of Javascript:
Code: Select all
<script type="text/javascript">
<!--
//Get POST data user & pass from form somehow
var loc = "http://" + user + ":" + pass + "@www.whateverurl.com/";
window.location = loc;
//-->
</script>


Hope this helps.

-Mike
mwa103
100+ Club
 
Posts: 206
Joined: Mon Mar 07, 2005 10:55 pm


Who is online

Users browsing this forum: No registered users and 8 guests