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

GitHub repository using Git Bash command

  To add a project to a GitHub repository using Git Bash command line, you can follow these steps: Create a new repository on GitHub by logg...