PDA

View Full Version : login script user not found & adding date of birth to data base



coolglen
21 May 2011, 08:11 AM
i am getting very annoyed with php everything i wright i get a error of some kind and its ever easy to fix, anyway this time i got my login script working i could log into my dummy account no problem so i set that aside and started making my register script i have got that all finished and n i have created a account with that and tried to login to it using my login script but it doesn't find my account in the data base i get the else statement from "if ($numrows !=0)"


<?php

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

include ("connect.php");

if ($username && $password)
{

$queryget = mysql_query ("SELECT * FROM users WHERE username='$username' AND password='password'");
$numrows = mysql_num_rows($queryget);
if ($numrows != 0)
{

$_SESSION['username'] = $username;

echo "You have been logged in. <a href='members.php'> Go to members area.</a>";

}
else
{
echo "Your username was not found.<a href='index.php'>Register here.</a>";
}
}
else
{
echo "You did not provide the proper info needed for login.";
include ("loginpage.php");
}

?>

p.s. i also have md5 encryption on the register script and id also like to know how to add it to the loin script so it finds the right password, that's not why i am having these troubles though because i made a dummy account without an encryption to test it.

and as for the adding the date to the database.


i am trying to make a registration script for my website iv got it mostly done but i am wondering how to get the date of birth into the database with my format.

i am using a drop down menu for the date of birth

like this..

<select name='birthdate1' id='birthdate1'><option value='0'>--Day--</option>

<select name=;birthdate2' id='birthdate2'><option value='0'>--Month--</option>

<select name='birthdate3' id='birthdate3'><option value='0'>--Year--</option>

and in my php code i have

$fullname = $_POST['name'];
$username = $_POST['username'];
$password = $_POST['password'];
$cpass= $_POST['cpass'];
$email = $_POST['email'];
$cemail = $_POST['cemail'];
$dob1 = $_POST['birthdate1'];
$dob2 = $_POST['birthdate2'];
$dob3 = $_POST['birthdate3'];
and to insert it into my data base i use

$register = mysql_query ("INSERT INTO users VALUES('','$username',$password')
since the date of birth has 3 "attributes"($dob1, $dob2, $dob3) i hope that's what there called :S correct me if i am wrong, anyway back to the point
how can i get the date of birth into the database properly?

nafirici
22 May 2011, 10:48 AM
i am trying to make a registration script for my website iv got it mostly done but i am wondering how to get the date of birth into the database with my format.

You should store birthday's as datetime, which is the format of yyyy-mm-dd. Then you can either use php or mysql's DATE_FORMAT to change it to how you want it to display.


p.s. i also have md5 encryption on the register script and id also like to know how to add it to the loin script so it finds the right password, that's not why i am having these troubles though because i made a dummy account without an encryption to test it.
For this I would select the password hash that matches the username entered and then use the same md5 hash on the password they entered and compare the one from the database and the one entered. If they match, than the user entered the correct password.

You should also salt the password for added security.