Jump to content

[SOLVED] login/register help


thisisnuts123

Recommended Posts

hey so i found the following tutorial

 

http://www.phpfreaks.com/tutorials/17/1.php

 

can i make this work with my script?

 

<?php
$connection = mysql_connect(localhost', ''username, 'pass');
$password = $_POST[password];
$pass = md5($password);
$db = mysql_select_db('game', $connection);
$sql = "SELECT id FROM user WHERE username='$_POST[username]' AND password='$pass'";

$result = mysql_query($sql);
$num = mysql_num_rows($result);

if ($num > 0) {
        //USER AND PASS ARE CORRECT
$id = mysql_fetch_assoc($result);

setcookie("auth", "yes", time()+3600);
setcookie("id", $id['id']);
setcookie("username", $id['username']);


header ("Location: main.php");

}else {

header ("Location: incorrect.php");

};

?> 

All of the Tutorials on PHP Freaks have been pretty thoroughly tested, and seem to work well on a majority of server configurations, but of course YMMV is in full effect.

 

Also, these Tutorials are examples, and written with very simplistic, if not insecure in some cases, coding. You should use the code to 'guide you' on getting it integrated with your existing code. Once you have it doing what you expect, then appropriately 'harden' it for security concerns.

 

PhREEEk

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.