These are the errors coming in:
Notice: Undefined variable: name in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 25
Notice: Undefined variable: email in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 25
Notice: Undefined variable: age in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 25
Notice: Undefined variable: dept in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 25
Notice: Undefined variable: year in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 25
Fatal error: Uncaught Error: Call to undefined method mysqli::execute() in C:\xampp\phpMyAdmin\Book Shop\connect.php:26 Stack trace: #0 C:\xampp\phpMyAdmin\Book Shop\signUp.php(14): include() #1 {main} thrown in C:\xampp\phpMyAdmin\Book Shop\connect.php on line 26
CODE HTML:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width", initial-scale=1, shrink-to-fit=no>
<meta name="author" content="Harsh Kumar Sharma">
<meta name="description" content="BookShop For Second Hand books For College Level">
<meta name="keywords" content="BookShop , Second Hand">
<meta charset="UTF-8">
<title>ICEM Book Shop</title>
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,500,600" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500i" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="signUp.css">
</head>
<body> <?php include 'connect.php'; ?>
<div class="nav">
<div class="logo">
<a href="#">
<img src="Images/logo_main.JPG" style="height: 40px ; width: 40px"></a>
<a href="signIn.html"><p style="margin:0px; font-size:35px ; color: #ffffff; display:inline-block; position: absolute">COLLEGE BOOKSTORE</p>
</a>
</div>
<div class="nav-menu">
<!-- Space for navigation menu -->
</div>
</div>
<div class="sq_box">
<center>
<h1 style="color: white;">Welcome to THE COLLEGE BOOKSTORE</h1>
<h1 style="color: white;">Sign Up</h1>
<p>Register here to be a part of US.</p>
</center>
<div style="padding:20px 0px 0px 140px; font-size: 20px;" id="form">
<form method="POST" action="connect.php">
<label for="text">Name</label><br>
<input type='text' placeholder="Full Name" id="name" name="name"><br>
<label for="text">Age</label><br>
<input type='text' placeholder="Age" id="age" name="age"><br>
<label for="email">Email</label><br>
<input type="email" placeholder="Email" id="email" name="email"><br>
<label for="text">Department</label><br>
<input type="radio" id="computer" name="department">
<label for="computer">Computer Department</label><br>
<input type="radio" id="mechanical" name="department">
<label for="mechanical">Mechanical Department</label><br>
<input type="radio" id="civil" name="department">
<label for="civil">Civil Department</label><br><br>
<label for="text">Year</label><br>
<input type="radio" id="FE" name="year">
<label for="computer">FE</label>
<input type="radio" id="SE" name="year">
<label for="mechanical">SE</label>
<input type="radio" id="TE" name="year">
<label for="civil">TE</label>
<input type="radio" id="BE" name="year">
<label for="civil">BE</label><br><br>
<label for="password">Password</label><br>
<input type='password' placeholder="Password" id="password" name="password"><br>
<label for="password">Confirm Password</label><br>
<input type='password' placeholder="Confirm Password" id="con_password"><br>
<br><br>
<button type="submit" name="submit"><b>Submit</b></button><br><br>
</form>
</div>
</div>
<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-analytics.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.19.1/firebase-database.js"></script>
<script src="login.js"></script>
</body>
</html>
PHP:
<?php
$servername = "localhost";
$username = "root";
$password = "" ;
$database = "bookshop";
$conn = new mysqli($servername, $username, $password , $database);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
exit();
}
if(isset($_POST["submit"])){
$name = $_POST["name"] ;
$email = $_POST["email"];
$age = $_POST["age"];
$dept = $_POST["department"];
$year = $_POST["year"];
$password = $_POST["password"];
}
$sql = "INSERT INTO `userinfo`(`Name`, `Age`, `E-mail`, `Department`, `Year`, `Password`)VALUES (?,?,?,?,?,?) ";
$stmtinsert = $conn->prepare($sql);
$names = array($name,$email,$age,$dept,$year,$password);
$result = $conn->execute($names);
if($result)
{
echo "Successfully Saved ";
}
else
{
echo "error occured ";
}
?>