Pages

Thursday, December 15, 2011

ragister page

ragiteration page::

//Database Information

require "config.php";

//Connect to database


$name = $_POST['name'];
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$company = $_POST['company'];
$telephone = $_POST['telephone'];
$post = $_POST['post'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$city = $_POST['city'];
$country = $_POST['country'];


// lets check to see if the username already exists

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
echo "I'm sorry but the Username you specified has already been taken. 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, company, telephone, post, add1, add2, city, country)
VALUES('$name', '$email','$username', '$password', '$company', '$telephone', '$post', '$add1', '$add2', '$city', '$country' )";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered Now go to login page Login Now ";

// mail user their information

$yoursite = 'www.tdsl-fm.com';
$webmaster = 'admin';
$youremail = 'info@tdsl-fm.com';

$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at our web site.

To login, simply go to our web page and enter in the following details in the login form:

Username: $username

Password: $password



Please print this information out and store it for future reference.



Thanks,

$webmaster";

$header="From:www.tdsl-fm.com\r\n";


$header.="Content-type: text/html \r\n";
mail($username, $subject, $message, $header);

echo "Your information has been mailed to your email address.";

?>



login page::


require "config.php";

session_start();
$username = $_POST['username'];
$password = $_POST['password'];
$query = mysql_query ("select * from users where username ='$username' and password='$password' LIMIT 1 ");



if (mysql_num_rows($query)!= 1) {
$error = "Bad Login";
echo $error;
include "index.html";

} else {

$_SESSION['username'] = "$username";
header("Location: admin.php");
}

?>

0 comments:

Post a Comment

 
Powered by Blogger