Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-07-2007, 11:29 AM   PM User | #1
[V]enom
New Coder

 
Join Date: Jul 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
[V]enom is an unknown quantity at this point
Login

Hi,
I would like to create my own login... on my website...
with PHP and MySQL, I've created a database called dieknights, with a table called memb_info
and now I want to have a login on my index.php, how do I do that?
1. create link to login.php ?
or
2. put the login on index.php with include();
or
3. put the login on index.php in a frame?
or
...

now my example:
I've sepereated it:
//index.php
<a href="login.php">To the Login</a>
__________________________________
//login.php
<form action="loggedin.php" method="post">
Name: <input type="text" name="membid"><br>
Passwort:<input type="text" name="pwid"><br>
<input type="submit" value="Login">
</form>
__________________________________
//loggedin.php
<?php
//Variable
$name = $_POST['membid'];
$pw = $_POST['pwid'];
//Check:
if (isset($name) && $pw != "")
{
//SQL query(code):
what goes here? I think:
if $pw = pwd_id("SELECT * FROM memb_info WHERE memb_id=$name");
or something...
?>

what do i need to put at the sql query i mean how can i make a check if the $name exists and if yes, check if the $pw is the right one....

I would be very thankful for help!

Last edited by [V]enom; 07-07-2007 at 12:30 PM..
[V]enom is offline   Reply With Quote
Old 07-07-2007, 12:38 PM   PM User | #2
[V]enom
New Coder

 
Join Date: Jul 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
[V]enom is an unknown quantity at this point
nobody?

nobody got a clue?
[V]enom is offline   Reply With Quote
Old 07-07-2007, 03:12 PM   PM User | #3
unrelenting
Regular Coder

 
Join Date: Jan 2007
Posts: 142
Thanks: 9
Thanked 1 Time in 1 Post
unrelenting is an unknown quantity at this point
Quote:
Originally Posted by [V]enom View Post
nobody got a clue?
If I knew how I'd be glad to help but just googling pointed me to this:

http://www.trap17.com/forums/php-sim...ial-t7887.html

Here's another really easy one:

http://www.tutorialized.com/tutorial...in-script/9963

Last edited by unrelenting; 07-07-2007 at 03:15 PM..
unrelenting is offline   Reply With Quote
Old 07-07-2007, 04:06 PM   PM User | #4
SMGames
New Coder

 
Join Date: Jul 2007
Location: UK
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
SMGames is an unknown quantity at this point
This is how i have mine, which will show the users info:

Code:
<?php

$username="*****";
$password="*****";
$database="*****";

mysql_connect('******',$username,$password);
@mysql_select_db($database) or die("Unable to select database");

$query = "SELECT * FROM users"; 
	 
$result = mysql_query($query) or die(mysql_error());


while($row = mysql_fetch_array($result)){

echo 
'<table border="1" width="650" bordercolor="#c0c0c0"><tr><td width="80">'.$row['id']. '</td>'. 
'<td width="120">'.$row['loginname']. '</td>'.
'<td width="120">'.$row['password']. '</td>'. 
'<td width="120">'.$row['createdate']. '</td>'.
'<td width="120">'.$row['name']. '</td>'.
'<td width="30">'.$row['age']. '</td>'. 
'<td width="150">'.$row['email']. '</td>'.
'<td width="30">'.$row['warn']. '</td></tr></table>';

echo "";
}
?>
Just change the stuff to what you need, i have a full working login /registering thing if you would like any code for that just say? BY PMING ME, I MAY NOT COME HERE AGAIN!!
__________________
http://www.smgames.staticfire.co.uk Under construction, Currently hiring mods and admins anyone interested pm me.

Last edited by SMGames; 07-07-2007 at 04:08 PM..
SMGames is offline   Reply With Quote
Old 07-07-2007, 04:53 PM   PM User | #5
rfresh
Regular Coder

 
Join Date: Jun 2007
Location: Los Angeles
Posts: 545
Thanks: 81
Thanked 5 Times in 5 Posts
rfresh is an unknown quantity at this point
Here is an outline of how I do this in PHP:

1. Login.php is a link on my home page. If the user wants to login then they click on this link and it displays the login.php page.

2. User logs in with username and pw. The login.php script calls login.dispatcher.php which processes the login data at the server:
a. checks login username and pw vars to make sure they not empty (strlen() == 0)
b. open database and find username entered on login page. If not found dispatcher script calls login.usernotfound.php page.
c. open database and fetch password. Decrypt password using PHP's Mcrypt module. Compare DB pw to login pw. If no match dispatcher script calls login.badpw.php script.
d. If password matches then dispatcher sets valid user pw variable (or however you plan to determine pw is valid) and calls what ever page you want next to be displayed.

Notes: For testing, you'll have to write two stub php scripts:
create_pw.php
display_pw.php

These two test scripts will allow you to create a pw and store it encrypted into the DB and then read it back out, decrypt it, to make sure you can get an encrypted pw into the DB and back out again.
__________________
RalphF
Business Text Messaging Services
https://www.MobileTextingService.com
rfresh is offline   Reply With Quote
Old 07-07-2007, 06:17 PM   PM User | #6
[V]enom
New Coder

 
Join Date: Jul 2007
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
[V]enom is an unknown quantity at this point
secure?

is it secure?
antispam? antihack?

btw thanks!

i needed this for my project,
im trying to program a webborwser based game, like:
www.tribalwars.net
has anyone got a clue, what else i need?

Last edited by [V]enom; 07-07-2007 at 06:20 PM..
[V]enom is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:46 AM.


Advertisement
Log in to turn off these ads.