Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am having trouble to sign up for the php and it gives me this error Warning : mysqli_connect(): (HY000/1049): Unknown database 'lab' in C:xampphtdocslab1

I am having trouble to sign up for the php and it gives me this error

Warning: mysqli_connect(): (HY000/1049): Unknown database 'lab' in C:\xampp\htdocs\lab1 ew_user.php on line 8

I dont know if the code was different

here is the code

$username = "root";

$password = "";

$hostname = "localhost";

$dbname = "lab";

$selected = mysqli_connect($hostname, $username, $password, $dbname);

if(isset($_POST['user']) && isset($_POST['pass'])){

$user = $_POST['user'];

$pass = $_POST['pass'];

$query = "SELECT * FROM users WHERE username='$user'";

$result = mysqli_query($selected, $query);

if(mysqli_num_rows($result) > 0 ) { //check if there is already an entry for that username

echo "Username already exists!";

}else{

$query = "INSERT INTO users (username, password) VALUES ('$user', '$pass')";

$result = mysqli_query($selected, $query);

header("location:index.php");

}

}

mysqli_closhe($selected);

?>

Signup!

" method="POST">

Username:

Password:


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

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

In bargaining, does it really matter who makes the first offer?

Answered: 1 week ago