VERY SIMPLE (but not for me) Please Help!
|
| View previous topic :: View next topic |
| Author |
Message |
Immortalis
Joined: 29 Sep 2006 Posts: 3
|
Posted: Fri Sep 29, 2006 6:54 pm Post subject: VERY SIMPLE (but not for me) Please Help! |
|
|
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. |
|
| Back to top |
|
 |
|
|
Immortalis
Joined: 29 Sep 2006 Posts: 3
|
Posted: Fri Sep 29, 2006 8:06 pm Post subject: Re: VERY SIMPLE (but not for me) Please Help! |
|
|
| Hmm.. noone knows how to do this? =( |
|
| Back to top |
|
 |
nighthawk 250+ Club

Joined: 11 Jun 2006 Posts: 415 Location: SFRJ
|
Posted: Fri Sep 29, 2006 9:20 pm Post subject: Re: VERY SIMPLE (but not for me) Please Help! |
|
|
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';
}
?>
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.
|
|
| Back to top |
|
 |
Immortalis
Joined: 29 Sep 2006 Posts: 3
|
Posted: Fri Sep 29, 2006 10:09 pm Post subject: Re: VERY SIMPLE (but not for me) Please Help! |
|
|
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) |
|
| Back to top |
|
 |
nighthawk 250+ Club

Joined: 11 Jun 2006 Posts: 415 Location: SFRJ
|
Posted: Sat Sep 30, 2006 8:32 pm Post subject: Re: VERY SIMPLE (but not for me) Please Help! |
|
|
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 |
|
| Back to top |
|
 |
mwa103 100+ Club
Joined: 07 Mar 2005 Posts: 206
|
Posted: Mon Oct 02, 2006 8:26 pm Post subject: Re: VERY SIMPLE (but not for me) Please Help! |
|
|
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: |
<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 |
|
| Back to top |
|
 |
|
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums. Click here to Register
If you are a current member here on DEVPPL, please login below:
|
|
|
|