I decided to post what i want to do exactly and get some ideas on how i could do it
I want to create a log in page where you can sign up and it gets stored in a database. Then when you sign up you get your account activated and then can log in.
The main purpose for logging in would be to fill out a time sheet form basically it will have a drop down box to select your job title. Position (jr sr etc) and then you type in the hours you have worked under Monday Tuesday Wednesday Thursday Friday then that would be submitted and sent into a database where it would be stored and could be added up and viewed
My PHP code so far
Login:
<?php
//Database Information
$dbhost = "localhost";
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass";
//Connect to database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
session_start();
$username = $_POST[‘username’];
$password = md5($_POST[‘password’]);
$query = “select * from users where username=’$username’ and password=’$password’”;
$result = mysql_query($query);
if (mysql_num_rows($result) != 1) {
$error = “Bad Login”;
include “login.html”;
} else {
$_SESSION[‘username’] = “$username”;
include “memberspage.php”;
}
?>
Register.php:
<?PHP
//Database Information
$dbhost = "localhost";
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass";
//Connects to the Database
mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());
$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = md5($_POST['password']);
$emailedpass = $_POST['password'];
// Check if username already exists
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);
if($username_exist > 0){
echo "That username has already been registered. Please pick another one";
unset($username);
include 'register.html';
exit();
}
// lf no errors present with the username
// use a query to insert the data into the database.
$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();
echo "You have successfully Registered";
// mail user their information
$yoursite = ‘dfdfg’;
$webmaster = ‘Admin’;
$youremail = ‘test@12345678itit.com’;
$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at.
To login, simply go to our <a href=""> Website </a> and enter in the following details in the login form:
Username: $username
Password: $emailedpass
Please print this information out and store it for future reference as we will be unabled to retrieve your password as it is encrypted into our database.
Thanks,
$webmaster";
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
echo "Your information has been sent to your email address.";
?>]
I want to set it to communicate with the database over php i can see at the top of both php files it says
$dbhost = "localhost";
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass"
1)How do i find the username and password out in xampp and how would i create the database so it communicates with it in phpmyadmin as i can't seem to work it out
2)How would i be able to view the data stored in the database and get a printout etc.
3) any suggestion of the coding for the time table page
Thanks in advance
ps.also half way through writing this post i saw you posted again. MYSQL was running at the time but when the error appears and i press open new myphpadmin window up i can use it without the error so i assume i ignore it