From 5edc0058c4b934b8afb807cfcb3de6507dc099df Mon Sep 17 00:00:00 2001
From: Raghav <raghavsmart1213@gmail.com>
Date: Thu, 27 Feb 2025 13:40:09 +0000
Subject: [PATCH] Tested database connection: Success

---
 _templates/head.php | 36 +++++++++++++++-------------
 libs/load.php       | 58 +++++++++++++++++++++++++++++++++++----------
 test.php            | 23 ++++++++++--------
 3 files changed, 77 insertions(+), 40 deletions(-)

diff --git a/_templates/head.php b/_templates/head.php
index 28b2fbc..c00bec1 100644
--- a/_templates/head.php
+++ b/_templates/head.php
@@ -1,26 +1,28 @@
 <head>
-    <script src="/photogram-project-php/assets/js/color-modes.js"></script>
+	<script src="/photogram-project-php/assets/js/color-modes.js"></script>
 
-    <meta charset="utf-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <meta name="description" content="">
-    <meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
-    <meta name="generator" content="Hugo 0.122.0">
-    <title>Album example · Bootstrap v5.3</title>
+	<meta charset="utf-8">
+	<meta name="viewport" content="width=device-width, initial-scale=1">
+	<meta name="description" content="">
+	<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
+	<meta name="generator" content="Hugo 0.122.0">
+	<title>Album example · Bootstrap v5.3</title>
 
-    <link rel="canonical" href="https://getbootstrap.com/docs/5.3/examples/album/">
+	<link rel="canonical" href="https://getbootstrap.com/docs/5.3/examples/album/">
 
-    
 
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3">
 
-    <link href="/photogram-project-php/assets/dist/css/bootstrap.min.css" rel="stylesheet">
+	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3">
 
-    <!-- CSS for login and signup page -->
+	<link href="/photogram-project-php/assets/dist/css/bootstrap.min.css" rel="stylesheet">
+
+	<!-- CSS for login and signup page -->
+
+	<!-- Checks if the file is exists -->
+	<?if (file_exists($_SERVER['DOCUMENT_ROOT'].'/photogram-project-php/assets/dist/css/'.basename($_SERVER['PHP_SELF'], ".php") . '.css')) {?>
+	<link
+		href="/photogram-project-php/assets/dist/css/<?=basename($_SERVER['PHP_SELF'], ".php")?>.css"
+		rel="stylesheet">
+	<?}?>
 
-    <!-- Checks if the file is exists -->
-    <?if(file_exists($_SERVER['DOCUMENT_ROOT'].'/photogram-project-php/assets/dist/css/'.basename($_SERVER['PHP_SELF'],".php") . '.css')){?>
-        <link href="/photogram-project-php/assets/dist/css/<?=basename($_SERVER['PHP_SELF'], ".php")?>.css" rel="stylesheet">
-    <?}?> 
-    
 </head>
\ No newline at end of file
diff --git a/libs/load.php b/libs/load.php
index 2dc45d2..55780e9 100644
--- a/libs/load.php
+++ b/libs/load.php
@@ -1,14 +1,46 @@
 <?php
-    function load_template($name){
-    
-        include $_SERVER['DOCUMENT_ROOT']. "/photogram-project-php/_templates/$name.php";
-    }
-
-    function validate_credentials($username, $password){
-        if($username == "raghav@gmail.com" and $password == "raghav"){
-            return true;
-        }else{
-            return false;
-        }
-    }
-?>
\ No newline at end of file
+function load_template($name)
+{
+
+	include $_SERVER['DOCUMENT_ROOT'] . "/photogram-project-php/_templates/$name.php";
+}
+
+// Function to validate the credentials.
+function validate_credentials($username, $password)
+{
+	if ($username == "raghav@gmail.com" and $password == "raghav") {
+		return true;
+	} else {
+		return false;
+	}
+}
+
+// Connecting to database
+function signup($username, $password, $email, $phone)
+{
+	$servername = "mysql.selfmade.ninja";
+	$username = "raghav";
+	$password = "R1a2g1h3av";
+	$dbname = "raghav_photogram";
+
+	// Create connection
+	$conn = new mysqli($servername, $username, $password, $dbname);
+	// Check connection
+	if ($conn->connect_error) {
+		die("Connection failed: " . $conn->connect_error);
+	}
+	else{
+		print("Connect Success!");
+	}
+
+// 	$sql = "INSERT INTO MyGuests (firstname, lastname, email)
+// VALUES ('John', 'Doe', 'john@example.com')";
+
+// 	if ($conn->query($sql) === TRUE) {
+// 		echo "New record created successfully";
+// 	} else {
+// 		echo "Error: " . $sql . "<br>" . $conn->error;
+// 	}
+
+	$conn->close();
+}
diff --git a/test.php b/test.php
index 7404032..710ebbd 100644
--- a/test.php
+++ b/test.php
@@ -1,16 +1,19 @@
 <pre>
     <?php
-    print("_SERVER\n");
-    print_r($_SERVER);
-    print("_GET\n");
-    print_r($_GET);
-    print("_POST\n");
-    print_r($_POST);
+    include 'libs/load.php';
+    // print("_SERVER\n");
+    // print_r($_SERVER);
+    // print("_GET\n");
+    // print_r($_GET);
+    // print("_POST\n");
+    // print_r($_POST);
 
-    print("_FILE\n");
-    print_r($_FILES);
+    // print("_FILE\n");
+    // print_r($_FILES);
 
-    print("_COOKIE\n");
-    print_r($_COOKIE);
+    // print("_COOKIE\n");
+    // print_r($_COOKIE);
+
+    signup("","","","");
     ?>
 </pre>
\ No newline at end of file
-- 
GitLab