Whats wrong with this code??

DoubleAA

Baseband Member
Messages
33
I watched a video tutorial but it was a bit hard to see...
Soo what do i need to change in order for this to work?

PHP:
<?php

$connection = mysql_connect(localhost, prefix_user, password);
$db = mysql_select_db(prefix_dbname, $connection);

$sql = "SELECT id FROM user
            WHERE username= ' $_POST(username)'
            AND password= ' $_POST(password)' ";
            
$result = mysql_query($sql);
$num = mysql_num_rows($result);

if ($num > 0| )

$id = mysql_fetch_assoc($result);

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

header ("Location: main.php");

}else {

header ("Location: incorrect.php");
);

?>

And how would i set up my databases with this code? [The names of them]
[And yes i have the login forum on another html page]
<html>
<head>
<title>Login Form</title>
</head>

<body>
<form name=login action=login.php method=post>

Username: <input type=text name=username>
<br>
Password: <input type=text name=username>
<br>
<input type=submit value='Login'>

</form>
</body>
</html>

Please help (DAA)
 
first you need to change this:

localhost, prefix_user, password
To something like
localhost, root, password

Then you need to create a table called 'users', with the columns - 'id','username','password'
 
Back
Top Bottom