Thursday 15 November 2018

To find errors in php Code

⚙ Start At the Beginning of script  

<?php
error_reporting();
Your script/code goes here....
?>

Monday 12 November 2018

Sublime Text 3.1.1 Serial key build is 3176 Step By Step

1. Step-1 click on help from menu bar 2. Step-2 click on insert license 3. Step-3 Copy this Whole code given Below From BEGIN LICENSE to END LICENSE
—– BEGIN LICENSE —–
sgbteam
Single User License
EA7E-1153259
8891CBB9 F1513E4F 1A3405C1 A865D53F
115F202E 7B91AB2D 0D2A40ED 352B269B
76E84F0B CD69BFC7 59F2DFEF E267328F
215652A3 E88F9D8F 4C38E3BA 5B2DAAE4
969624E7 DC9CD4D5 717FB40C 1B9738CF
20B3C4F1 E917B5B3 87C38D9C ACCE7DD8
5F7EF854 86B9743C FADC04AA FB0DA5C0
F913BE58 42FEA319 F954EFDD AE881E0B
—— END LICENSE ——
Step-4 Paste the whole key in place of insert licence begin with From BEGIN LICENSE to END LICENSE
Step-5 click on submit and Enjoy The Registred Sublime Sublime Text 3.1.1

Sunday 14 October 2018

CUSTOM POST TYPE IN WORDPRESS

function create_whychoosetaxhint_post_type() {
register_post_type( 'whychoosetaxhint',
array(
'labels' => array(
'name' => esc_html__('Why Choose Tax Hint', 'whatwedo-list'),
'singular_name' => esc_html__('Why Choose Tax Hint', 'whatwedo-list'),
'add_new' => 'Add New',
'add_new_item' => 'Add New Why Choose Tax Hint',
'edit_item' => 'Edit Why Choose Tax Hint',
'new_item' => 'New Why Choose Tax Hint',
'view_item' => 'View Why Choose Tax Hint',
'search_items' => 'Search Why Choose Tax Hint',
'not_found' =>  'Nothing Found',
'not_found_in_trash' => 'Nothing found in the Trash',
'parent_item_colon' => ''
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => 'dashicons-building',
//'rewrite' => true,
'rewrite' => array('slug' => 'whychoosetaxhint'),
//'rewrite' => array('slug' => '%education_type%'),
'capability_type' => 'post',
        'has_archive' => true,
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'revisions', 'page-attributes', 'comments'),
'taxonomies'   => array( 'whychoosetaxhint',  'post_tag' )
)
);
}
add_action( 'init', 'create_whychoosetaxhint_post_type' );

register_taxonomy("whychoosetaxhint_type", array("whychoosetaxhint"), array(
"hierarchical" => true,
"label" => "Categories",
"singular_label" => "Category",
'show_ui' => true,
        'query_var' => 'whychoosetaxhint_type',
        "rewrite" => true
));

Wednesday 22 August 2018

UPLOAD AND UPDATE IMAGE IS OPTIONAL 


<?php
include('db.php');
$id=$_GET['id'];
$message='';
//$id = (isset($_GET['id']) ? $_GET['id'] : '');
if (isset($_POST['update']))
{
        $fileName='';
$first=$_POST['first'];
$last=$_POST['last'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$gender=$_POST['gender'];
$hobbies=$_POST['hobbies'];
$arr=implode(",",$hobbies);
$message=$_POST['Message'];
//$file = $_FILES['file'];
  date_default_timezone_set('Asia/Kolkata');
  $created_date= date('Y-m-d h:i:s');
  $upload_path = 'uploads';  
  $new_image_name="";
  $new_image_name=$_FILES["file"]["name"];
  $allowed =  array('png' ,'jpg','jpeg');
  $ext = pathinfo($new_image_name, PATHINFO_EXTENSION);

  move_uploaded_file($_FILES['file']['tmp_name'], "uploads/".$new_image_name);

   $actual_link = "http://$_SERVER[HTTP_HOST]";
   $actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
   $folder_path = dirname($actual_link); 
   
if(!empty($new_image_name)){
   $image= $folder_path.'/uploads'.'/'.$new_image_name;
//echo $fileName;
//die;
}
else{
$select= "SELECT image FROM forms WHERE id='".$id."'";
//echo $select;
//die;
$query=mysqli_query($connection,$select);
$num=mysqli_num_rows($query);
if($num > 0)
{
while($row=mysqli_fetch_array($query))
  {
$image=$row['image'];
//echo $fileName;
//die;
  }
}
}
$sql =  "UPDATE forms SET first_name='$first',last_name='$last',email='$email',mobile='$mobile',gender='$gender',hobbies='$arr',message='$message',image='$image',created_date='$created_date' WHERE id='".$id."'";
        $query=mysqli_query($connection,$sql);
    if($query)
{
header('location:select.php');
exit;
}
}


?>
<form class=form action="" method="post" enctype="multipart/form-data">
<div class="mesage">
<?php if(!empty($message)) { echo $message; } ?>
</div>
<?php $select1= "SELECT * FROM forms WHERE id='".$id."'";
//echo $select1;
//die;
$result1 = mysqli_query($connection,$select1);
$num1=mysqli_num_rows($result1);
//echo $num1;
//die;
if($num1){
$row1 = mysqli_fetch_array($result1);
?>
<head><h2>Update From</h2></head>
<form class=form action="" method="post" enctype="multipart/form-data">
<p>First Name:<input type="text" name="first" placeholder="First Name" value= <?php echo $row1['first_name'];?>>
Last Name:<input type="text" name="last" placeholder="Last Name" value= <?php echo $row1['last_name'];?>></p>
<p>Email:<input type="email" name="email" placeholder="Email" value= <?php echo $row1['email'];?>>
Mobile:<input type="tele" name="mobile" placeholder="Mobile" value= <?php echo $row1['mobile'];?>></p>

<p>
Gender: 
Male<input type="radio" name="gender" value="Male" <?php if($row1['gender']=="Male"){echo "checked";}?>/>

Female<input <?php if($row1['gender']=="Female"){echo "checked";}?> type="radio" name="gender" value="Female"/>
</p>

<p>Hobbies:
<?php 
$chkbox=$row1['hobbies'];
$arr=explode(",",$chkbox);
//print_r($arr);
//die;
?>
Singing <input <?php if(in_array("Singing",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Singing" />
Dancing <input <?php if(in_array("Dancing",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Dancing" />
Art <input <?php if(in_array("Art",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Art" />
cricket <input <?php if(in_array("Cricket",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Cricket" /><br>
</p>

<p>
<textarea name="Message" rows="5" cols="40" placeholder="Enter Message">
<?php echo $row1['message'];?>
</textarea>
</p>
<p>
<td><img height=70px width=40px src="<?php echo $row1['image'];?>" />
<input type ="file" name="file"><br>
</td>
</p>
<p>

<input type="submit" name="update" value="Update" >
</p>
<?php } ?>
</form>

Saturday 18 August 2018

UPDATE

6. update.php

<?php
include('db.php');
$id=$_GET['id'];
//$id = (isset($_GET['id']) ? $_GET['id'] : '');
if (isset($_POST['update']))
{
//$arr=implode(",",$hobbies);
$first=$_POST['first'];
//echo $first;
$last=$_POST['last'];
//echo $last;
$email=$_POST['email'];
//echo $email;
$mobile=$_POST['mobile'];
//echo $mobile;
$gender=$_POST['gender'];
//echo $gender;
$hobbies=$_POST['hobbies'];
$arr=implode(",",$hobbies);
//echo $arr;
$message=$_POST['Message'];
$sql = "UPDATE forms SET first_name='$first',last_name='$last',email='$email',mobile='$mobile',gender='$gender',hobbies='$arr',message='$message' WHERE id='".$id."'";
//echo $sql;
//die;
$qeury=mysqli_query($connection,$sql);
if($qeury){
header('location:select.php');
exit;
}
else
{
echo 'not update';
}
}


$select= "SELECT * FROM forms WHERE id='".$id."'";
$result = mysqli_query($connection,$select);
while($row = mysqli_fetch_array($result)){


?>

<form action="" method="post" enctype="multipart/form-data">
<p>First Name:<input type="text" name="first" placeholder="First Name" value= <?php echo $row['first_name'];?>>
Last Name:<input type="text" name="last" placeholder="Last Name" value= <?php echo $row['last_name'];?>></p>
<p>Email:<input type="email" name="email" placeholder="Email" value= <?php echo $row['email'];?>>
Mobile:<input type="tele" name="mobile" placeholder="Mobile" value= <?php echo $row['mobile'];?>></p

<p>
Gender: 
Male<input type="radio" name="gender" value="Male" <?php if($row['gender']=="Male"){echo "checked";}?>/>

Female<input <?php if($row['gender']=="Female"){echo "checked";}?> type="radio" name="gender" value="Female"/>
</p>

<p>Hobbies:
<?php 
$chkbox=$row['hobbies'];
$arr=explode(",",$chkbox);
//print_r($arr);
//die;
?>
Singing <input <?php if(in_array("Singing",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Singing" />
Dancing <input <?php if(in_array("Dancing",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Dancing" />
Art <input <?php if(in_array("Art",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Art" />
cricket <input <?php if(in_array("Cricket",$arr)){echo "checked";}?> type="checkbox" name="hobbies[]" value="Cricket" /><br>
</p>

<p>
<textarea name="Message" rows="5" cols="40" placeholder="Enter Message">
<?php echo $row['message'];?>
</textarea>

<input type="submit" name="update" value="Update" >
</p>
<?php } ?>
</form>


Friday 17 August 2018

FORM INSERT SELECT AND DELETE

1. Form.php  
<form action="insert.php" method="post" enctype="multipart/form-data">
<p>First Name:<input type="text" name="first" placeholder="First Name">
Last Name:<input type="text" name="last" placeholder="Last Name"></p>
<p>Email:<input type="email" name="email" placeholder="Email">
Mobile:<input type="tele" name="mobile" placeholder="Mobile"></p>
<p>
Gender:
Male<input type="radio" name="gender" value="Male" >
Female<input type="radio" name="gender" value="Female" >
</p>
<p>Hobbies:
Singing <input type="checkbox" name="hobbies[]" value="Singing">
Dancing <input type="checkbox" name="hobbies[]" value="Dancing">
Art <input type="checkbox" name="hobbies[]" value="Art">
cricket <input type="checkbox" name="hobbies[]" value="Cricket"><br>
</p>
<p>
<textarea name="Message" rows="5" cols="40" placeholder="Enter Message">
</textarea>
<!__<input type ="file" name="upload"><!__<br>
<input type="submit" name="submit" value="Submit" >
</p>
<br><a href="select.php" type="submit" name="logout">Show</a>
</form>
2. db.php
<?php
$servername="localhost";
$username="root";
$password="123456789";
$db_name="database_name";//your database Name
$connection=mysqli_connect($servername,$username,$password,$db_name);
// Check connection
if (!$connection) {
    die("Connection failed: " . mysqli_connect_error());
}
//echo "Connected successfully";
?>
3. insert.php
<?php
require "db.php";//for database connection
if (isset($_POST['submit'])){ $first=$_POST['first'];
$last=$_POST['last'];
$email=$_POST['email'];
$mobile=$_POST['mobile'];
$gender=$_POST['gender'];
$hobbies=$_POST['hobbies'];
$arr=implode(",",$hobbies);
$message=$_POST['Message'];
  //******************************INSERT QUERY START HERE******************************
  $query="INSERT INTO forms(first_name,last_name,email,mobile,gender,hobbies,message)
  VALUES('$first','$last','$email','$mobile','$gender','$arr','$message')";
  $insert=mysqli_query($connection,$query);
  if (!$insert==0){
  echo "Record inserted Successfully";
  }
  else
  {
  echo "validations Failed";
  }
}
?>
4.  select.php
<table align="center" >
<table style="width:900px;"border="5" >
<tr><th colspan="9"><h1>Records</h1></th></tr>
<tr align="center">
<td><h3>ID</h3></td>
<td><h3>FIRST NAME</h3></td>
<td><h3>LAST NAME</h3></td>
<td><h3>EMAIL</h3></td>
<td><h3>MOBILE</h3></td>
<td><h3>GENDER</h3></td>
<td><h3>HOBBIES</h3></td>
<td><h3>MESSAGE</h3></td>
<td><h3>ACTION</h3></td>
</tr>
<?php
//require "db.php";
//if(isset($_POST['submit'])){
include('db.php');
$select= "SELECT * FROM forms";
$result = mysqli_query($connection,$select);
while($row = mysqli_fetch_array($result)){
?> <tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['first_name'];?></td>
<td><?php echo $row['last_name'];?></td>
<td><?php echo $row['email'];?></td>
<td><?php echo $row['mobile'];?></td>
<td><?php echo $row['gender'];?></td>
<td><?php echo $row['hobbies'];?></td>
<td><?php echo $row['message'];?></td>
<td><a href='delete.php?id=<?php echo $row['id']; ?>'>Delete</a></td>
</tr> <?php } ?>
</table>
5. delete.php
<table align="center" >
<table style="width:900px;"border="5" >
<tr><th colspan="9"><h1>Records</h1></th></tr>
<tr align="center">
<td><h3>ID</h3></td>
<td><h3>FIRST NAME</h3></td>
<td><h3>LAST NAME</h3></td>
<td><h3>EMAIL</h3></td>
<td><h3>MOBILE</h3></td>
<td><h3>GENDER</h3></td>
<td><h3>HOBBIES</h3></td>
<td><h3>MESSAGE</h3></td>
<td><h3>ACTION</h3></td>
</tr>
<?php
//require "db.php";
//if(isset($_POST['submit'])){
include('db.php');
$select= "SELECT * FROM forms";
$result = mysqli_query($connection,$select);
while($row = mysqli_fetch_array($result)){
?> <tr>
<td><?php echo $row['id'];?></td>
<td><?php echo $row['first_name'];?></td>
<td><?php echo $row['last_name'];?></td>
<td><?php echo $row['email'];?></td>
<td><?php echo $row['mobile'];?></td>
<td><?php echo $row['gender'];?></td>
<td><?php echo $row['hobbies'];?></td>
<td><?php echo $row['message'];?></td>
<td><a href='delete.php?id=<?php echo $row['id']; ?>'>Delete</a></td>
</tr> <?php } ?>
</table>


Thursday 16 August 2018

Error: Fatal error: Cannot redeclare exp() in PHP

Error: Fatal error: Cannot redeclare exp() in 

The message says Cannot redeclare and that means that the function already exists.
exp() is a built-in function in php.


You can do it like this
function my_exp($value1,$value2) {
  return $value1 ** $value2;
}
echo my_exp(2,8);//prints 256;
Or you can use the built-in function pow()
echo pow(2,8);//prints 256