Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysqli_connect("localhost","root","","realestatecompany");
- if(!$con) {
- echo "Error";
- }
- //$con->close();
- ?>
- <?php
- require_once 'dbconnector.php';
- class userAccount {
- public $userName;
- public $userPass;
- public $userType;
- public function __construct ($UserName, $Password, $Type, $con) {
- $this->userName = $UserName;
- $this->userPass = $Password;
- $this->userType = $Type;
- }
- public function writeInDB() {
- $sql = "INSERT INTO login (userName,userPass,userType) values (".$this->userName.",".$this->userPass.",".$this->userType.")";
- if ($con->query($sql) === TRUE) {
- echo "Record Added successfully";
- } else {
- echo "Error Adding record: " . $conn->error;
- }
- }
- public function editInDB($userNewAccount, $userID) {
- $a = $userNewAccount->userName;
- $b = $userNewAccount->userPass;
- $c = $userNewAccount->userType;
- $sql = "UPDATE login SET userName =".$a.", userPass ='".$b."', userType =".$c." WHERE userID =".$userID;
- echo $sql;
- }
- }
- $x = new userAccount("Heba", "Taba3", 1, $con);
- $x->writeInDB();
- Notice: Undefined variable: con in D:xampphtdocsswprojectobjects.php on line 14
- Fatal error: Uncaught Error: Call to a member function query() on unknown in D:xampphtdocsswprojectobjects.php:14 Stack trace: #0 D:xampphtdocsswprojectobjects.php(29): userAccount->writeInDB() #1 {main} thrown in D:xampphtdocsswprojectobjects.php on line 14
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement