Old 04-11-2004   #1 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
Login codeing

Working on my first big site project and am a little puzzled by the code for having a login and password to another site. I got the code to work for the text box the password box and the button, but can not figure out how to make each link so it throws you to another site..

He is my code so far:

<tr>
<td align="left" valign="top"><input type="text" name="name" id="loginName" maxlength="35"></td>
</tr>
<tr>
<td align="left" valign="top" height="25" width="75" style="padding-top: 5px"><img src="password.gif"></td>
</tr>
<td align="left" valign="middle"><input type="password" name="password" id="loginPassword" maxlength="35"></td>
</tr>
<tr>
<td height="25" width="75" style="padding-left: 23px; padding-top: 10px"><input type="image" src="submit.gif" alt="Sign In"></td>
</tr>
<tr>

I am using tables through out this project with minor CSS to adjust size and spacing. if you can help pls do

oh and i forgot to introduce myself, i will have to do that in the intro forum...lol
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-11-2004   #2 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
relized

I come to relize it is probably going to have to be java scripted. I understand how to do the code, but am still fuzzy on how to make it multi passworded. Where more then one password, one per user, can be used to enter the portion of the site. i could be totally wrong in teh direction i am heading, so input from anyone familiar with this would be apreciated
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-11-2004   #3 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
found it

Well i found a tutorial on login codes etc. and it will be php that i will be using. grrr. No nothign about php but hey its a good time for me to learn. wish me luck
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-11-2004   #4 (permalink)
Lazarus' Child
 
malboroman's Avatar
 
Join Date: Nov 2003
Location: The Netherlands
Posts: 603

Send a message via MSN to malboroman Send a message via Skype™ to malboroman
If I take a quick look at your HTML code I see that all your form elements are there, but they are just floating around in the page... You have to put the in a form... You do that by using the <form></form tags... It should look something like this:

Code:
<form name="formname" method="post" action="login.php">

<tr>
<td align="left" valign="top"><input type="text" name="name" id="loginName" maxlength="35"></td>
</tr>
<tr>
<td align="left" valign="top" height="25" width="75" style="padding-top: 5px"><img src="password.gif"></td>
</tr>
<td align="left" valign="middle"><input type="password" name="password" id="loginPassword" maxlength="35"></td>
</tr>
<tr>
<td height="25" width="75" style="padding-left: 23px; padding-top: 10px"><input type="image" src="submit.gif" alt="Sign In"></td>
</tr>
<tr>

</form>
just to explain what all the things mean:

'name' can be anything... it's just for you to identify the form...

'method' should always be post, you can also use the get option but the first one is better.

'action' is the destination where all your information inputted at the form will be sent to...

Hope I have it clear for you, if you have any questions just post them...
__________________


"Only the dead have seen the end of war."

- Plato
malboroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-11-2004   #5 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
Talking crystal

Yeah forgot about that part. I have been in the process of learning three code languages in full over the past couple of days, and just over looked taht part fo teh code. Thank you for pointing that out...now back to work...If i find myself stuck in a rut again i will post away
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-12-2004   #6 (permalink)
Lazarus' Child
 
malboroman's Avatar
 
Join Date: Nov 2003
Location: The Netherlands
Posts: 603

Send a message via MSN to malboroman Send a message via Skype™ to malboroman
I've been learning HTML, PHP and CSS in the past few months too... And I can say that I know my part of HTML and CSS... PHP is still one of the things I need to practice...

I taught myself by trying to create my own scripts and then looking for all the right code... I suggest you just keep on reading, that works best.
__________________


"Only the dead have seen the end of war."

- Plato
malboroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-12-2004   #7 (permalink)
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
php is the best for login systems, when I have some time, I will write up a sample for you.
__________________
Order is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-13-2004   #8 (permalink)
Lazarus' Child
 
malboroman's Avatar
 
Join Date: Nov 2003
Location: The Netherlands
Posts: 603

Send a message via MSN to malboroman Send a message via Skype™ to malboroman
Actually I already made one for myself ( for learning purposes) and at least it works....

//connect.php
Code:
<?



$host = 'localhost';

$user = 'username';

$pass = 'password';

$db = 'database';



mysql_connect($host,$user,$pass) or die(mysql_error());

mysql_select_db($db);



?>
//login.php
Code:


<?php  
session_start(); 

include('connect.php');

if ($_POST['username'] && $_POST['password']) {   
       

    $passcoded = md5($_POST['password']);   
    $username = $_POST['username'];   
       

    session_register('username');   
    session_register('passcoded');   

    header('Location: loggedin.php');   
    exit;   
}   

else {


?>
<body background="../images/bg.gif">
<form method="post" action="login.php"> 
    Username:<input type="Text" name="username"><br> 
    Password:<input type="Password" name="password"><br> 
    <input type="Submit" name="Submit" value="Login"> 
</form> 

<? }  ?>
//loggedin.php
Code:
<?php 
session_start(); 
$controle == 0; 

include ('function.php');   

$controle = password($username, $passcoded); 

if ($controle == 1) {   
    echo '<center><p>You are logged in as <b>$username</b><p></center>';    
           
?> 
<html> 
<head> 
<title></title> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> 
<body background="../images/bg.gif">
<center><table width="150" border="0" align="center" cellpadding="0" cellspacing="0"> 
  <tr> 
    <td align="center"><a href=?page=members>Members</a></td> 
  </tr> 
   <tr> 
    <td align="center"><a href=?page=logout>Uitloggen</a></td> 
  </tr> 
</table></center>  
</body> 
</html> 
<?php 
}   
else {   
    echo '<br><p>You are not logged in. Click <a href=?page=login>here</a> to log in.</p>';   
}   

?>
//function.php
Code:
<?php  
function connect() { 
    $db_host = 'localhost';   
    $db_login = 'username';   
    $db_pass = 'password';   
    $db_database = 'database';   
    mysql_connect('$db_host', '$db_login', '$db_pass') or die('MySQL connection failed.');   
    mysql_select_db('$db_database')or die('Selecting database failed.');   
}   

function password($username, $passcoded) {   
    connect(); 

   $pass_from_database = ' '; 


    $sql = 'SELECT password FROM members WHERE username LIKE '$username' ORDER BY id DESC';   
    $result = mysql_query($sql) or die(mysql_error());   

    if ($row = mysql_fetch_object($result)) { 
        $pass_from_database = md5($row->password);   

        if($passcoded == $pass_from_database) {   
            return 1;    
        }   
        else {   
            echo 'Not a valid combination of username/password';   
            return 0;   
        }   
    }   
    else {   
        echo 'Invalid username';   
        return 0;   
    }   
}   

?>
This is not all, but it's a start...

btw... I needed to create a mysql database for this one...
Code:
CREATE TABLE `members` ( 
id int(11) NOT NULL auto_increment, 
username varchar(10),   
password varchar(10),   
PRIMARY KEY (`id`) 
) TYPE=MyISAM;
There could be some errors in it, cause I'm still kind of a n00b when it comes to php and I wrote it in dutch, but I translated some things to English. I might have forgotten some things...
__________________


"Only the dead have seen the end of war."

- Plato

Last edited by malboroman; 04-13-2004 at 12:32 AM..
malboroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-13-2004   #9 (permalink)
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
You did something that few learners of php do, you used the right encryption for passwords, which will make things secure to a point. The downside is that you will not be able to see what the passoword is, since md5 is one way.

Most applications in php use md5, just differently, vBulletin goes a little overboard their passwords are encrypted like so:

md5(md5($password), $salt);

$salt is a random string for any user, generated at login, and changes everytime you log in, a little paranoid, but secure. The reason I know this little secret about vBulletin, I had to make a script to check users in the database.
__________________
Order is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-14-2004   #10 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
Good STuff

Yeah i am going to wait to learn php and finish the rest of teh webpage. I will refer back to this link when i get that far for more help. I dont even know how to make MySQL databases or anything yet. Pretty much in the dark with php.
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-15-2004   #11 (permalink)
Lazarus' Child
 
malboroman's Avatar
 
Join Date: Nov 2003
Location: The Netherlands
Posts: 603

Send a message via MSN to malboroman Send a message via Skype™ to malboroman
It ain't even that hard to learn.... Once you've take the first few steps the rest comes along...
__________________


"Only the dead have seen the end of war."

- Plato
malboroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2004   #12 (permalink)
Registered User
 
Stiker's Avatar
 
Join Date: Apr 2004
Location: Kansas
Posts: 120

Send a message via AIM to Stiker
really

seems like complex code, probably seems that way since i have not read much into it. will take a look at it this week.
Stiker is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2004   #13 (permalink)
Lazarus' Child
 
malboroman's Avatar
 
Join Date: Nov 2003
Location: The Netherlands
Posts: 603

Send a message via MSN to malboroman Send a message via Skype™ to malboroman
If you know the syntax and you have some common sence, it's just trial and error until it works. Worked for me anyways...
__________________


"Only the dead have seen the end of war."

- Plato
malboroman is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-18-2004   #14 (permalink)
Local Biorust Beast
 
Order's Avatar
 
Join Date: Oct 2003
Location: San Diego, CA, USA
Posts: 2,253

Send a message via AIM to Order Send a message via MSN to Order Send a message via Yahoo to Order
http://www.php.net/manual

Best resource if you dont know how something works.
__________________
Order is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 04-19-2004   #15 (permalink)
Incredible Indelible Etiquette
 
Young Spartan's Avatar
 
Join Date: Oct 2003
Location: Hobe Sound, Florida
Posts: 1,751

Send a message via AIM to Young Spartan Send a message via MSN to Young Spartan Send a message via Yahoo to Young Spartan
Quote:
Originally Posted by Digital
http://www.php.net/manual

Best resource if you dont know how something works.
That is 2nd best, in my opinion.

www.phpfreaks.com has most of that, plus about 90 million php freaks sitting in a forum just waiting lifelessly to answer your dumb questions.
Young Spartan is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
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 On
Forum Jump


All times are GMT +1. The time now is 05:57 PM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT