Thursday, 30 May 2019

Use Of MySQL Where Clause in php 7.3

The WHERE clause is used to extract only those records that fulfill a specified condition.
where clause is a part of select command . it is used to fetch data from a table . we basically use this clause to filter out our results. by using where clause we can select particular set of records based specified condition.

create database name dbname
table name :  empInfo
column : id , name , eid,mob

create connection.php page

<?php

$con=mysqli_connect("localhost","username","password","dbname") or die(mysqli_error());


?>

create index.php 

<?php 

include("connection.php");

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>page title</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<link href="style.css" rel="stylesheet" type="text/css" />



<style type="text/css">

<!--

.style4 { color: #0066CC;

font-weight: bold;

font-size: 16px;

}

-->

</style>

</head>

<body>

       

                      <?php

                      //select values from empInfo table where column=value

                     $data="SELECT * FROM empInfo where emp_id='devesh@gmail.com'";
$val=mysqli_query($con,$data);
echo "<table border='1'>";
echo "<tr><th>Emp_id</th><th>Name</th><th>Email</th><th>Mobile</th></tr>";

while(list($id,$name,$eid,$mob) =  mysqli_fetch_array($val))
{
echo "<tr>";
echo "<td>".$id."</td>";
echo "<td>".$name."</td>";
echo "<td>".$eid."</td>";
echo "<td>".$mob."</td>";
echo "</tr>";
}
echo "</table>";
 ?>

                          

                  <?php //}?>

              
</body>

</html>



Redirect http to https using .htaccess

Redirect your http page to https page using .htaccess file
create .htaccess file in your root folder and paste given code. Change red text to your domain name

<---- start code here ---->

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sakhihosting\.in [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.sakhihosting.in/$1 [R=301,L]


<---- end code here ---->

Redirect Specified Folder

If you want to force SSL on a specific folder, insert the code below into a .htaccess file placed in that specific folder:
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R=301,L]


Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folderwith your actual domain name and folder you want to force the SSL on.