Skip to main content

Posts

Showing posts from December, 2015

PHP CRUD Operations

Table Query ___________________________________________________________________ CREATE TABLE IF NOT EXISTS `emp` (   `id` int(11) NOT NULL,   `name` varchar(50) DEFAULT NULL,   `salary` int(11) DEFAULT NULL,   `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; config.php ________________________________________________________________________________ <?php $server = "localhost"; $user = "root"; $password = ""; $dbname = "newdb"; $conn =  new mysqli($server,$user,$password,$dbname); if($conn->connect_error) { die("connection failed:".$conn->connect_error); } ?> index.php ___________________________________________________________________ <?php include 'config.php'; ?> <html> <head> </head> <style> table, th, td  { padding: 8px;     border: 1px solid black...

HTML 5 pattern validation

<!DOCTYPE html> <html> <head> <title>html5 patterns val</title> </head> <body> <form action=""> Email :   <input type="email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,3}$" required> Min Char:  <input type="password" name="pw" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters" required> Search: <input type="search" name="search" pattern="[^'\x22]+" title="Invalid input" required> Password:   <input type="password" name="pw" pattern=".{6,}" title="Six or more characters" required> Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three let...

Indian Rupee Symbol in PHP or HTML

Rupee Symbol &#8377; OR  &#x20A8; 

PHP Mail

<?php     if(isset($_POST['send']))    {       $name     =$_POST['name'];       $email    =$_POST['email'];       $ number    =$_POST[' number '];       $comments =$_POST['comments'];              $to="test@domain.com";                           $subject  = "Enquiry";          $message  = "<h3>Enquiry from example.com</h3>";          $message .= "<h4>Name        : $name</h4>";          $message .= "<h4>Email       : $email</h4>";          $message .= "<h4>Contact No  : $contact</h4>";          $message .= "<h4>Comments ...

send a id by GET method

db.php _________________________________________________________________ <?php  $query=mysql_query("INSERT INTO employee VALUES ('$id','$name')"); if($query)  {      header('location:index.php?msg'); }?> _________________________________________________________________ index.php _________________________________________________________________ <?php if(isset($_GET['msg'])) {  $comp = $_GET['msg']; ?>     <div class="alert alert-success">           Thank you, this is message by GET id      </div> <?php } ?> _________________________________________________________________

session to send a text or data

db.php _____________________________________________________ <?php  $query=mysql_query("INSERT INTO employee VALUES ('$id','$name')"); if($query)  {      $_SESSION['msg']="inserted successfully";      header('location:index.php'); }?> _____________________________________________________ index.php _____________________________________________________ <?php if (isset($_SESSION['msg'])) { ?>       <div class="alert alert-info">            <?php echo $_SESSION['msg'];?>       </div> <?php unset($_SESSION['msg']);   }  ?> _____________________________________________________