Last active
October 18, 2018 10:59
-
-
Save mahamudul310/17d2a6fee4882e07af17d70cf3032ea1 to your computer and use it in GitHub Desktop.
OOP Database Connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Student { | |
// public function __construct() { | |
// | |
// } | |
public function save_student_info($data){ | |
$host_name='localhost'; | |
$user_name='root'; | |
$password =''; | |
$db_name='db_sudent_info'; | |
$connection = mysqli_connect($host_name,$user_name,$password,$db_name); | |
if(!$connection){ | |
die('Connection Fail'.mysqli_errno($connection)); | |
} | |
$sql = "INSERT INTO tbl_student (student_name,phone_number,email_address,address)VALUES('$data[student_name]','$data[phone_number]','$data[email_address]','$data[address]')"; | |
if(mysqli_query($connection, $sql)){ | |
$message="Student info save successfully"; | |
return $message; | |
}else{ | |
die('Query problem'.mysqli_error($connection)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment