Monday, January 20, 2014

PHP with OOPS

here you have to construct two PHP files 

----------------------------------------------------------------------------------------------

 index.php

<?php
include("connection.php");
$obj=new apoo;
if(isset($_POST['SUB']))
{
   
    $un=$_POST['uname'];
    $up=$_POST['upass'];
   
    $yyy=$obj->AddUss($un,$up);
    }
//header("location:registration.php");
    ?>

<html>
<body>
<form method="post" action="">
username
<input type="text" name="uname" />
password

<input type="text" name="upass" />

<input type="submit" name="SUB" />

</form>
</body>
</html>


--------------------------------------------------------------------------------------------------------

connection.php


<?php

session_start();
class CLASSNAME
{
    var $connect;
    function __construct()
    {
        $this->connect=new MySQLi("localhost","root","","sun12k");
        echo "success";
    }
  
    function AddUss($un,$up)
    {
        $addU=$this->connect->prepare("insert into`nametable`(firstname,lastname)VALUES(?,?);");
        $addU->bind_param("ss",$un,$up);
        $addU->execute();
    echo "success2";
       
        //    header("location:home.php");       
        }
}
?>

No comments:

Post a Comment

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide

How to Host a Laravel Project on Hostinger’s hPanel: A Step-by-Step Guide If you're looking to host a Laravel project on Hostinger’s hPa...