summcat
03-28-2003, 09:32 PM
hey all-
i have this login code, but im not sure what commands i need to put into the phpmyadmin sql box?
If someone could produce some code, i could produce $$.
<?php
// SCRIPT THAT VERIFIES USERNAME AND GETS ID
$username = $_POST['username'] or exit('Couldn\'t assign username');
$password = $_POST['password'] or exit('Couldn\'t assign password');
// Connect to sql database the_database
$link = mysql_pconnect('localhost', 'mysql_username', 'mysql_password') or exit('Could not connect to the server. Please try again later.');
//print 'Connected to SQL<br />';
mysql_select_db('the_database', $link) or exit('Could not speak with server. Please try again later.');
//print 'Connected to database<br />';
//get id
$query = "SELECT id FROM users WHERE username = '$username' and password = '$password'";
$result = mysql_query("$query") or exit('Error looking up id');
if (mysql_num_rows($result) == 0) {
$error = 'You are not in the system. Please re-check your username and password or <a href="register.html">register</a>.';
exit("$error");
}
$row = mysql_fetch_array($result);
$id = $row['id'];
mysql_free_result($result);
//mysql_close($link); //don't use for persistent connections
// inserts mainpage.php verbatim
require 'mainpage.php';
?>
i have this login code, but im not sure what commands i need to put into the phpmyadmin sql box?
If someone could produce some code, i could produce $$.
<?php
// SCRIPT THAT VERIFIES USERNAME AND GETS ID
$username = $_POST['username'] or exit('Couldn\'t assign username');
$password = $_POST['password'] or exit('Couldn\'t assign password');
// Connect to sql database the_database
$link = mysql_pconnect('localhost', 'mysql_username', 'mysql_password') or exit('Could not connect to the server. Please try again later.');
//print 'Connected to SQL<br />';
mysql_select_db('the_database', $link) or exit('Could not speak with server. Please try again later.');
//print 'Connected to database<br />';
//get id
$query = "SELECT id FROM users WHERE username = '$username' and password = '$password'";
$result = mysql_query("$query") or exit('Error looking up id');
if (mysql_num_rows($result) == 0) {
$error = 'You are not in the system. Please re-check your username and password or <a href="register.html">register</a>.';
exit("$error");
}
$row = mysql_fetch_array($result);
$id = $row['id'];
mysql_free_result($result);
//mysql_close($link); //don't use for persistent connections
// inserts mainpage.php verbatim
require 'mainpage.php';
?>
