I'm a beginner in PHP OOP. I know about basic OOP using PHP. Now I wanted to create a simple form submit code using OOP. I want to save a name in database. But I don't know what to write for first parameter in mysqli_query
Here's my code:
<?php
class dbConnect{
private $host="localhost";
private $user="root";
private $pass="";
private $db="oodb";
public function Connect(){
$conn=mysqli_connect($this->host, $this->user, $this->pass, $this->db);
if($conn){
echo "Connected";
}
}
}
$dbConn=new dbConnect();
$dbConn->Connect();
class Signup{
public function Insert($value){
if(isset($_REQUEST["sub"])){
$query="INSERT INTO signup(name) VALUES('$value')";
//FOLLING STATEMENT IS INCORRECT
$queryrun=mysqli_query($dbConn->Connect(), $query);
echo "Inserted";
}
else{
echo "Error";
}
}
}
$sign=new Signup();
if(isset($_POST['id'])){
$sign->Insert($_POST['id']);
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form name="form1" method="post">
<input type="text" name="id">
<input type="submit" name="sub">
</form>
</body>
</html>
Also, could you please tell me if I'm using OOP in a right way not? I think there are many mistakes.