Click here to Skip to main content
15,883,796 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
register.class.php code

class DataBase
    public $connection;
    private $hostname;
    private $username;
    private $password;
    private $db;

    public function connect($host,$user,$pass,$dtb)

        return $this->connection=mysqli_connect($host,$user,$pass,$dtb) or die("Could not connect");

    public function insert($fields,$data,$table)

            $sql='insert into '.$table.'('.$queryfield.') values("'.$queryvalues.'")';

                return TRUE;

        }catch(Exception $e){
            echo "Error:" .$e;


register.php code


include 'register.class.php';

$con=new DataBase();


    if($res)echo"1 record inserted";




<!DOCTYPE html>
<html lang="en">
        <meta charset="utf-8" />
        <form action="register.php" method="post" enctype="multipart/form-data">
            <input type="text" name="username" required value=""><br><br>
            <input type="text" name="email" required value=""><br><br>
            <input type="password" name="password" required value=""><br><br>
            <input type="submit" name="submit" value="Submit">


unable to insert record page show blank without inserting record
E.F. Nijboer 2-Feb-15 9:11am    
Are you creating a test site to explain SQL injection? Or is this a serious attempt to create a website?
Rakesh 00 2-Feb-15 9:20am    
Hi thanx for reply this is just for test.I am new to oops concept... Big Grin | :-D
E.F. Nijboer 2-Feb-15 9:24am    
I would really advize you to read up on proper handling of values used in your sql statement. A well known joke about it can be found on xkcd:

Have a look here:
Rakesh 00 2-Feb-15 9:24am    
I will be really thankfull if you will give me complete code with oops concept to update, insert, select, delete data from database :P
W Balboos, GHB 3-Feb-15 15:02pm    
It looks to me like your using the wrong delimiter in this statement:

$queryvalues=implode(' "," ',$data);

I would think you want something more like:
$queryvalues=implode(" ',' ",$data);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900