Skip to main content

Posts

Database Connection with PHP PDO MYSQL

PDO Connection MYSQLI // Create Connection with Pdo\ $dsn = "mysql:host=localhost; dbname=test;"; $db_user = "root"; $db_password = ""; try{     $conn = new PDO("$dsn", "$db_user","$db_password");    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);     echo "Connected"; }catch(PDOException $a){     echo "Connection Failed". $a->getMessage(); }
Recent posts

AngularJs Crud Insert Data

<?php $server="localhost"; $user="root"; $pass="iq123"; $db="test"; $conn= mysqli_connect($server,$user,$pass,$db); if (!$conn){ echo "mysqli_error().'Database not connected'"; } ?> <?php include("conn.php"); $data=json_decode(file_get_contents("php://input")); $name=$data->name; $price=$data->price; $quantity=$data->quantity; $sql="Insert into product(name,price,quantity)values('$name','$price','$quantity')"; $query=mysqli_query($conn,$sql); ?> <!DOCTYPE> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>InsertData</title> <script src="js/angular.js" language="javascript" type="text/javascript"></script> <script src="js/angular.min.js" language="javascript" type="text

Angular Js Form Validation

<!DOCTYPE html> <html> <script src="angular.min.js"></script> <body> <h2>Validation Example</h2> <form ng-app="myApp" ng-controller="validateCtrl" name="myForm" novalidate> <p>Username:<br> <input type="text" name="user" ng-model="user" required> <span style="color:red" ng-show="myForm.user.$dirty && myForm.user.$invalid"> <span ng-show="myForm.user.$error.required">Username is required.</span> </span> </p> <p>Email:<br> <input type="email" name="email" ng-model="email" required> <span style="color:red" ng-show="myForm.email.$dirty && myForm.email.$invalid"> <span ng-show="myForm.email.$error.required">Email is required.</span> <span ng-show="myForm.emai

Crud Angular JS

<!DOCTYPE HTML> <html ng-app="myapp"> <head> <title>Angular Js Crud</title> <script type="text/javascript" src="angular.min.js"></script> </head> <body ng-controller="productController"> <table cellpadding="2" cellspacing='2' border="1px"> <tr> <th>Id </th> <th>Name </th> <th>Price </th> <th>Quantity </th> <th>option </th> </tr> <tr ng-repeat="product in listproduct"> <td>{{product.id}}</td> <td>{{product.name}}</td> <td>{{product.price}}</td> <td>{{product.quantity}}</td> <td> <a href="#" ng-click="del(product.id)">Delete</a> | <a href="#" ng-click="selectEdit(product.id)">Edit</a> &l

Factorial Fibinicci

Factorial <center> <form action = "" method="post">     <h2>Factorial Number</h2>     <table>         <tr><td><input type="number" name="aa" /></td></tr>         <tr><td><input type="submit" name="save" value="Submit" /></td></tr>         </table> </form> </center> <?php $x=$_POST['save']; $y=$_POST['aa']; function getFactorial($y){     $fact=1;     for($i=1;$i<=$y;$i++)         $fact *=$i;     return $fact;         } if(isset($x)and($y))     {     echo 'Factorial of Number  : <strong>'.  getFactorial($y).'</strong>'; } ?> Fibinicci <?php $a=0; $b=1; for($i=0;$i<=10;$i++){     if($i==0){         $c=0;     }else{                 $c=$a+$b;         $a=$b;         $b=$c;     }         echo $c." ";

PrimeNumber

<?php $submit=$_POST['submit']; $prime=$_POST['n']; //if($n===1){ //    echo"not a prime or composite no"; //} if($prime==1){     echo"not a prime or composite no"; } for($index=2;$index<=$prime/2;$index++){         if($prime%$index===0){         $set=1;     }   } if($set){     echo $prime." is a composite number"; }else{     echo $prime." is a prime number"; } ?> <form action="#" method="post" enctype="multipart/form-data">         <table>         <tr>             <td><input type="text" name="n"></td>             <td><input type="submit" name="submit" value="submit"></td>         </tr>     </table>     </form>

FormValidation

<?php ?> <form action="valid2.php" method="post" enctype="multipart/form-data"style="background-color: pink;">         <center> <h1>Student Registration Form</h1></center>         <table align="center">         <tr>             <td>Name :</td>             <td> <input type="text" name="uname"></td>         </tr>        <tr>             <td>E_mail</td>             <td><input type="text" name="email"></td>                 </tr>         <tr>             <td>password :</td>             <td> <input type="password" name="pass"></td>         </tr>         <tr>             <td>Gender :</td>                       <td>Male<input type="radio" name="sex"&