Skip to content

Commit

Permalink
database setup file updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Fahad-Md-Kamal committed Feb 26, 2019
1 parent ad163c0 commit e301caa
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 73 deletions.
Binary file added img/1551108825.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions php/DB/DB_Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,7 @@

<?php


function DataBaseCreate(){
$host = "localhost";
$user = "root";
$pass = "";

$conn = new mysqli($host,$user,$pass);

$sql = "CREATE DATABASE IF NOT EXISTS e_shop";

if ($conn->connect_error) {
die("Error:".$conn->connect_error);
}
else{
$conn->query($sql);
}
}

function DataBaseConnection(){
DataBaseCreate();

$host = "localhost";
$user = "root";
Expand All @@ -32,6 +13,4 @@ function DataBaseConnection(){

}



?>
50 changes: 50 additions & 0 deletions php/DB/db_setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php


function dbSetup(){
$conn = new mysqli("localhost","root","");

$sql = "CREATE DATABASE IF NOT EXISTS e_shop";

if ($conn->connect_error) {
die("Error:".$conn->connect_error);
}
else{
$conn->query($sql);
}

include_once 'DB_Connection.php';
$conn = DataBaseConnection();

$sql = "CREATE TABLE users(
id INT(10) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
email VARCHAR(100),
pass VARCHAR(20)
)";

if ($conn->error) {
die("Failed to Create table users:" . $conn->error);
}
$conn->query($sql);


$sql = "CREATE TABLE products(
Id INT(5) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
price INT(10),
details VARCHAR(300),
Image VARCHAR(30)
)";

if ($conn->error) {
die("Failed to Create table users:" . $conn->error);
}

$conn->query($sql);


}
dbSetup();
header("location:../../index.php");
?>
39 changes: 0 additions & 39 deletions php/DB/table_Create.php

This file was deleted.

10 changes: 1 addition & 9 deletions php/productRegistrationCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@

include_once "DB/DB_Connection.php";
$conn = DataBaseConnection();
$sql = "CREATE TABLE products(
Id INT(5) PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50),
price INT(10),
details VARCHAR(300),
Image VARCHAR(30)
)";

$conn->query($sql);


$sql = "SELECT * FROM products WHERE name = '$name'";

Expand Down
3 changes: 0 additions & 3 deletions php/userReg.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
$_SESSION['msg'] = "Re-entered password didn't matched.<br> Enter password again.";

}else{
include_once "DB/table_Create.php";
TableCreate();

include_once "DB/DB_Connection.php";
$conn = DataBaseConnection();

Expand Down
2 changes: 1 addition & 1 deletion templating/product_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="col-lg-4 col-md-6 mb-4">
<div class="card h-100">
<a href="#"><img class="card-img-top" src="img/<?=$row['image']?>" alt=""></a>
<a href="#"><img class="card-img-top" src="img/<?=$row['Image']?>" alt=""></a>
<div class="card-body">
<h4 class="card-title">
<a href="#"><?=$row['name']?></a>
Expand Down

0 comments on commit e301caa

Please sign in to comment.