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");

};

?> 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.