General PHP question.
Posted: Sun Jan 03, 2010 10:28 pm
Hi all.
Last time I was here, I said something about a project I was working on, called PHP Quick Journal (at least I think I said something about it). Well, I recently purchased a book on PHP to improve, and so far, I have been doing well with the project.
Still, though, I have questions.
I basically need to know: Will the following script work? It's supposed to serve as a log in page, and according to this website, my syntax is correct, however I have not tested it yet, so I just wanted to make sure. I will be testing it soon.
Last time I was here, I said something about a project I was working on, called PHP Quick Journal (at least I think I said something about it). Well, I recently purchased a book on PHP to improve, and so far, I have been doing well with the project.
Still, though, I have questions.
I basically need to know: Will the following script work? It's supposed to serve as a log in page, and according to this website, my syntax is correct, however I have not tested it yet, so I just wanted to make sure. I will be testing it soon.
Code: Select all
<?php
/*
Ramen
*/
include('../files/functions.php'); //Include our functions.
//Check to see if the form has been submitted.
if (isset ($_POST['submit'])) {
if (($_POST['username'] == '') or ($_POST['password'] == '')) {
echo "Something was left blank. Please go back and try again.";
}
else {
connect(); //Connect to the database.
if (!connect()) {
die(mysql_error());
}
$check = "SELECT * FROM ".$prefix."users WHERE username == '{$_POST['username']}' && password == '{$_POST['password']}'";
mysql_query($check);
if (!$check) {
die ('There was a problem logging in. Please try again.');
}
else {
session_start();
$_SESSION['loggedin'] = 'yes';
echo "You have logged in successfully. <a href='index.php'>Click here to continue to the index.</a>";
}
}
}
else {
//Form stuff goes here.
}
?>