--------------------------------------------------------------------------------------
DATABASE
---------------------------------------------------------------------------------------
Create a database with name tour . Now copy paste the code below in a text file and save it with the name tour.sql .Import the sql file in your database created.
---------------------------------------------------------------------------------------------------------------
-- phpMyAdmin SQL Dump
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Oct 06, 2013 at 03:39 PM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `tour`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) DEFAULT NULL,
`passcode` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `username`, `passcode`) VALUES
(1, 'test', 'test');
-- --------------------------------------------------------
--
-- Table structure for table `contact`
--
CREATE TABLE IF NOT EXISTS `contact` (
`name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`message` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`name`, `email`, `message`) VALUES
('Kiran Shinde', 'djkiru07@gmail.com', 'A good Website...Keep it up!'),
('Rupesh Shinde', 'djruki007@gmail.com', 'Excellent...try to improve user interace'),
('Prasad Mane', 'pmane@gmail.com', 'I liked it.'),
('Durvesh Shinde', 'dshinde@gmail.com', 'Helped me to plan my trip..good effort.');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- version 3.5.2.2
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Oct 06, 2013 at 03:39 PM
-- Server version: 5.5.27
-- PHP Version: 5.4.7
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `tour`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin`
--
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(30) DEFAULT NULL,
`passcode` varchar(30) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `admin`
--
INSERT INTO `admin` (`id`, `username`, `passcode`) VALUES
(1, 'test', 'test');
-- --------------------------------------------------------
--
-- Table structure for table `contact`
--
CREATE TABLE IF NOT EXISTS `contact` (
`name` varchar(30) NOT NULL,
`email` varchar(30) NOT NULL,
`message` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Dumping data for table `contact`
--
INSERT INTO `contact` (`name`, `email`, `message`) VALUES
('Kiran Shinde', 'djkiru07@gmail.com', 'A good Website...Keep it up!'),
('Rupesh Shinde', 'djruki007@gmail.com', 'Excellent...try to improve user interace'),
('Prasad Mane', 'pmane@gmail.com', 'I liked it.'),
('Durvesh Shinde', 'dshinde@gmail.com', 'Helped me to plan my trip..good effort.');
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
CONFIG.PHP(config.php)
---------------------------------------------------------------------------------------
<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "tour";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
?>
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "tour";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Opps some thing went wrong");
mysql_select_db($mysql_database, $bd) or die("Opps some thing went wrong");
?>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
CONTACTS.HTML : (contacts.html)
---------------------------------------------------------------------------------------
<!DOCTYPE html>
<html lang="en">
<head>
<title>TourDeMumbai</title>
<meta charset="utf-8">
<style type="text/css">
label
{
font-weight:bold;
width:100px;
font-size:14px;
}
.box
{
border:#666666 solid 1px;
}
</style>
<script type="text/javascript">
function validateForm()
{
var name=document.forms["contact"]["name"].value;
var email=document.forms["contact"]["email"].value;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var message=document.forms["contact"]["message"].value;
if (name==null || name=="")
{
alert("First name must be filled out");
name.focus;
return false;
}
if (!filter.test(email))
{
alert('Please provide a valid email address');
email.focus;
return false;
}
if (message==null || message=="")
{
alert("Message must be filled out");
message.focus;
return false;
}
}
</script>
</head>
<body>
<div align="center">
<div style="width:400px; border: solid 1px #333333; " align="left">
<div style="background-color:#333333; color:#FFFFFF; padding:3px;"><b>Contact Form</b></div>
<div style="margin:30px">
<form id="contacts-form" name="contact" action="contact.php" method="post" onSubmit="return validateForm()";>
<table>
<tr>
<td>Your Name:</td>
<td><input type="text" name="name" value=""/></td>
</tr>
<tr>
<td>Your E-mail:</td>
<td><input type="text" name="email" value=""/></td>
</tr>
<tr>
<td>Your Message:</td>
<td><textarea name="message"></textarea></td>
</tr>
</table>
<div align="center"><input type="submit" value="Send">
<input type="reset" value="Clear"></div>
</form>
<div style="font-size:11px; color:#cc0000; margin-top:10px" align="center"><?php echo $error; ?></div>
</div>
</body>
</html>
<html lang="en">
<head>
<title>TourDeMumbai</title>
<meta charset="utf-8">
<style type="text/css">
label
{
font-weight:bold;
width:100px;
font-size:14px;
}
.box
{
border:#666666 solid 1px;
}
</style>
<script type="text/javascript">
function validateForm()
{
var name=document.forms["contact"]["name"].value;
var email=document.forms["contact"]["email"].value;
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var message=document.forms["contact"]["message"].value;
if (name==null || name=="")
{
alert("First name must be filled out");
name.focus;
return false;
}
if (!filter.test(email))
{
alert('Please provide a valid email address');
email.focus;
return false;
}
if (message==null || message=="")
{
alert("Message must be filled out");
message.focus;
return false;
}
}
</script>
</head>
<body>
<div align="center">
<div style="width:400px; border: solid 1px #333333; " align="left">
<div style="background-color:#333333; color:#FFFFFF; padding:3px;"><b>Contact Form</b></div>
<div style="margin:30px">
<form id="contacts-form" name="contact" action="contact.php" method="post" onSubmit="return validateForm()";>
<table>
<tr>
<td>Your Name:</td>
<td><input type="text" name="name" value=""/></td>
</tr>
<tr>
<td>Your E-mail:</td>
<td><input type="text" name="email" value=""/></td>
</tr>
<tr>
<td>Your Message:</td>
<td><textarea name="message"></textarea></td>
</tr>
</table>
<div align="center"><input type="submit" value="Send">
<input type="reset" value="Clear"></div>
</form>
<div style="font-size:11px; color:#cc0000; margin-top:10px" align="center"><?php echo $error; ?></div>
</div>
</body>
</html>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
CONTACT.PHP : (contact.php)
---------------------------------------------------------------------------------------
<?php
// Create connection
$con=mysqli_connect("127.0.0.1","root","","tour");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO contact (name, email, message)
VALUES
('$_POST[name]','$_POST[email]','$_POST[message]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "Thank you for contacting us.";
mysqli_close($con);
?>
// Create connection
$con=mysqli_connect("127.0.0.1","root","","tour");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="INSERT INTO contact (name, email, message)
VALUES
('$_POST[name]','$_POST[email]','$_POST[message]')";
if (!mysqli_query($con,$sql))
{
die('Error: ' . mysqli_error($con));
}
echo "Thank you for contacting us.";
mysqli_close($con);
?>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
LOGIN.PHP : (login.php)
---------------------------------------------------------------------------------------
<?php
include("config.php");
session_start();
$error="Enter your Credentials";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);
$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$error="Enter Credentials";
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
$_SESSION['login_user']=$myusername;
header("location: welcome.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tour The Mumbai</title>
<meta charset="utf-8">
<style type="text/css">
label
{ font-weight:bold;
width:100px;
font-size:14px;
include("config.php");
session_start();
$error="Enter your Credentials";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
// username and password sent from form
$myusername=addslashes($_POST['username']);
$mypassword=addslashes($_POST['password']);
$sql="SELECT id FROM admin WHERE username='$myusername' and passcode='$mypassword'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$error="Enter Credentials";
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)
{
$_SESSION['login_user']=$myusername;
header("location: welcome.php");
}
else
{
$error="Your Login Name or Password is invalid";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tour The Mumbai</title>
<meta charset="utf-8">
<style type="text/css">
label
{ font-weight:bold;
width:100px;
font-size:14px;
}
.box
{border:#666666 solid 1px;}
</style>
</head>
<body>
<div align="center">
<div style="width:300px; border: solid 1px #333333; " align="left">
<div style="background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
<div style="margin:30px">
<form action="" method="post">
<table cellspacing="10" cellpadding="5"><tr>
<td>UserName </td><td><input type="text" name="username" class="box"/></td><tr/><br>
<tr><td>Password </td><td><input type="password" name="password" class="box" /></td></tr>
</table><br>
<div align="center"><input type="submit" value=" Submit "/></div>
</form>
<div style="font-size:11px; color:#cc0000; margin-top:10px" align="center"><?php echo $error; ?></div>
</div>
</body>
</html>
.box
{border:#666666 solid 1px;}
</style>
</head>
<body>
<div align="center">
<div style="width:300px; border: solid 1px #333333; " align="left">
<div style="background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
<div style="margin:30px">
<form action="" method="post">
<table cellspacing="10" cellpadding="5"><tr>
<td>UserName </td><td><input type="text" name="username" class="box"/></td><tr/><br>
<tr><td>Password </td><td><input type="password" name="password" class="box" /></td></tr>
</table><br>
<div align="center"><input type="submit" value=" Submit "/></div>
</form>
<div style="font-size:11px; color:#cc0000; margin-top:10px" align="center"><?php echo $error; ?></div>
</div>
</body>
</html>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
WELCOME.PHP : (welcome.php)
---------------------------------------------------------------------------------------
<?php
include('lock.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>TourDeMumbai</title>
<meta charset="utf-8">
</head>
<body>
<a href="logout.php"><input type="button" style=" background-color:#999" border="1" value="Logout"/></a>
<h2>Contact <span>Details</span></h2>
<?php
$con=mysqli_connect("127.0.0.1","root","","tour");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM contact");
echo "<table border='5' cellspacing='5' cellpadding='5' bordercolor='#000000' >
<tr>
<th>Name</th>
<th>Email</th>
<th>Message</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['message'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
include('lock.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>TourDeMumbai</title>
<meta charset="utf-8">
</head>
<body>
<a href="logout.php"><input type="button" style=" background-color:#999" border="1" value="Logout"/></a>
<h2>Contact <span>Details</span></h2>
<?php
$con=mysqli_connect("127.0.0.1","root","","tour");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM contact");
echo "<table border='5' cellspacing='5' cellpadding='5' bordercolor='#000000' >
<tr>
<th>Name</th>
<th>Email</th>
<th>Message</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['message'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</body>
</html>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
LOGOUT.PHP : (logout.php)
---------------------------------------------------------------------------------------
<?php
session_start();
if(session_destroy())
{
header("Location: login.php");
}
?>
session_start();
if(session_destroy())
{
header("Location: login.php");
}
?>
---------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
LOCK.PHP : (lock.php)
---------------------------------------------------------------------------------------
<?php
include('config.php');
session_start();
$user_check=$_SESSION['login_user'];
$ses_sql=mysql_query("select username from admin where username='$user_check' ");
$row=mysql_fetch_array($ses_sql);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location: login.php");
}
?>
include('config.php');
session_start();
$user_check=$_SESSION['login_user'];
$ses_sql=mysql_query("select username from admin where username='$user_check' ");
$row=mysql_fetch_array($ses_sql);
$login_session=$row['username'];
if(!isset($login_session))
{
header("Location: login.php");
}
?>
---------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment