CliffLandin
Programmer
I am fairly new to mysql but have been using small snippets here and there while writing php pages. I have a site that I am creating that has a simple sign in page and a few other mysql uses.
The problem that I am having is that when I first go to the page and try to log on using my username and password it doesn't work. If I try again it works just fine.
I go to the next page where I create a trip number based on the last trip number and then I display it. It doesn't display it unless I refresh the page.
here is a sample of how I am checking the password with the user name:
<?php
session_start();
header("Cache-control: private");
$user = $_POST['username'];
$pass = $_POST['password'];
$link = mysql_connect("$something", "$someother", "$someone");
if (!$link) {
die("Could not connect: " . mysql_error());
}
mysql_select_db("dbName", $link)
or die("Could not select database");
$query = "SELECT password FROM table WHERE userName='$user'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$pass2 = $row[0];
mysql_close($link);
if (($user=="") or ($pass==""))
header("Location: elseif ($pass<>$pass2)
header("Location: else{
$_SESSION['user'] = $user;
header("Location: }
?>
It works fine on the second go 'round. The simple error checking works fine. I am sure that it is something fairly simple. As I said before, I am new to mysql.
Any help is appreciated.
Thanks,
When in doubt, go flat out!
The problem that I am having is that when I first go to the page and try to log on using my username and password it doesn't work. If I try again it works just fine.
I go to the next page where I create a trip number based on the last trip number and then I display it. It doesn't display it unless I refresh the page.
here is a sample of how I am checking the password with the user name:
<?php
session_start();
header("Cache-control: private");
$user = $_POST['username'];
$pass = $_POST['password'];
$link = mysql_connect("$something", "$someother", "$someone");
if (!$link) {
die("Could not connect: " . mysql_error());
}
mysql_select_db("dbName", $link)
or die("Could not select database");
$query = "SELECT password FROM table WHERE userName='$user'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
$pass2 = $row[0];
mysql_close($link);
if (($user=="") or ($pass==""))
header("Location: elseif ($pass<>$pass2)
header("Location: else{
$_SESSION['user'] = $user;
header("Location: }
?>
It works fine on the second go 'round. The simple error checking works fine. I am sure that it is something fairly simple. As I said before, I am new to mysql.
Any help is appreciated.
Thanks,
When in doubt, go flat out!