From 22412c35ceb5b72a5f2f7a8f172b7ed474349143 Mon Sep 17 00:00:00 2001
From: Rafael Leopoldo <66650046+Rafapoldo@users.noreply.github.com>
Date: Fri, 2 Oct 2020 10:54:02 -0300
Subject: [PATCH 1/3] specifying the README
---
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 883f83e..b43a4c6 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
-# Recharge-Website-Development-Series
+# Charging-Website-Development
+
+- Apllying functions from PHP 7.4.8 to connect a database
From e0966cd52407429fc13bad9bb4e71e7ff5095464 Mon Sep 17 00:00:00 2001
From: Rafael Leopoldo <66650046+Rafapoldo@users.noreply.github.com>
Date: Fri, 2 Oct 2020 10:55:43 -0300
Subject: [PATCH 2/3] Update
---
db.php | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/db.php b/db.php
index 9d13b42..373add1 100644
--- a/db.php
+++ b/db.php
@@ -1,12 +1,17 @@
select_db('DATABASE');
-$dbcon=mysql_connect('localhost','root','');
-$dbselect=mysql_select_db('recharge',$dbcon);
-
-if(!$dbcon OR !$dbselect){
- echo 'Database connection failed!';
-exit;
+
+if (!$dbcon) {
+ echo "Error: Failed to connect to the MySQL database." . PHP_EOL;
+ echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
+ echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
+ exit;
}
-
-?>
\ No newline at end of file
+
+echo "Success: Success when connecting to the MySQL database." . PHP_EOL;
+
+mysqli_close($dbcon);
+?>
From 57f767cbfadfd6512b5ecf71e4f8f2c9c528bce6 Mon Sep 17 00:00:00 2001
From: Rafael Leopoldo <66650046+Rafapoldo@users.noreply.github.com>
Date: Fri, 2 Oct 2020 10:56:27 -0300
Subject: [PATCH 3/3] Update
---
register.php | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/register.php b/register.php
index d4f0af1..fe23941 100644
--- a/register.php
+++ b/register.php
@@ -40,23 +40,23 @@
}
-$emch=mysql_query("SELECT * FROM users WHERE email='$email'");
+$emch = $mysqli->query("SELECT * FROM users WHERE email='$email'");
-if(mysql_num_rows($emch)>0){
-$errors[]='Email already registered with another account!';
-}
+ if(mysqli_num_rows($emch)>0){
+ $errors[]='Email already registered with another account!';
+ }
-$emcha=mysql_query("SELECT * FROM users WHERE number='$mobile'");
+$emcha= $mysql->query("SELECT * FROM users WHERE number='$mobile'");
-if(mysql_num_rows($emcha)>0){
-$errors[]='Mobile number already registered with another account!';
-}
+ if(mysqli_num_rows($emcha)>0){
+ $errors[]='Mobile number already registered with another account!';
+ }
if(empty($errors)){
- $doreg=mysql_query("INSERT INTO users (email,password,name,number,status,balance) VALUES ('$email','$password1','$name','$mobile','1','0')");
+ $doreg= $mysql->query("INSERT INTO users (email,password,name,number,status,balance) VALUES ('$email','$password1','$name','$mobile','1','0')");
if($doreg){
@@ -84,4 +84,4 @@
}
-?>
\ No newline at end of file
+?>