Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Open database in phpmyadmin: http://localhost/phpmyadmin Create a new database name login in phpmyadmin. Create a new table: users -- -- Table structure for table `users`

  1. Open database in phpmyadmin: http://localhost/phpmyadmin

  1. Create a new database name login in phpmyadmin.

  1. Create a new table: users

--

-- Table structure for table `users`

--

CREATE TABLE IF NOT EXISTS `users` (

`user_id` int(11) NOT NULL,

`username` varchar(50) NOT NULL,

`password` varchar(50) NOT NULL,

`name` varchar(50) NOT NULL

) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--

-- Dumping data for table `users`

--

INSERT INTO `users` (`user_id`, `username`, `password`, `name`) VALUES

(2, 'admin', 'admin', 'admin'),

(3, 'user', 'user', 'user');

--

-- Indexes for dumped tables

--

--

-- Indexes for table `users`

--

ALTER TABLE `users`

ADD PRIMARY KEY (`user_id`);

--

-- AUTO_INCREMENT for dumped tables

--

--

-- AUTO_INCREMENT for table `users`

--

ALTER TABLE `users`

MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=4;

/*!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 */;

  1. Create localhost connection: dbcon.php

$con = mysqli_connect("localhost","root","","login");

// Check connection

if (mysqli_connect_errno())

{

echo "Failed to connect to MySQL: " . mysqli_connect_error();

}

?>

  1. Create a session file: session.php

//Start session

session_start();

//Check whether the session variable SESS_MEMBER_ID is present or not

if (!isset($_SESSION['user_id']) || (trim($_SESSION['user_id']) == '')) {

header("location: index.php");

exit();

}

$session_id=$_SESSION['user_id'];

?>

  1. Create a file CSS style: style.css.

Run your files by localhost: http://localhost/project_name/register.php

Create main page: index.php

  1. Create links page after successful logged to system: home.php

include('dbcon.php');

include('session.php');

$result=mysqli_query($con, "select * from users where user_id='$session_id'")or die('Error In Session');

$row=mysqli_fetch_array($result);

?>

Welcome:

Log out

  1. Create Logout page: logout.php to destroy user sessions.

session_start();

session_destroy();

header('location:index.php');

?>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 1 Lncs 8055

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013 Edition

3642402844, 978-3642402845

More Books

Students also viewed these Databases questions