The most viewed posts

Registry Reviver

How to clean up Windows Computer

About Desktop Icons in Windows Computer

Driver Booster

How to make a computer secure and run faster

Myanmar font and keyboard for Windows

CCleaner

Web Development Services

Advanced System Care

some (JavaScript Array Method)

The most viewed items

Desktop Hard Disk

Dell Inspiron 5559

HP ProBook 430

SONY Playstation Portable

Laptop RAM

External Hard Disk

Laptop

ZilaStar ICT Jun 23 2019, 19:13:57

Deleting table in a database

<?php
$server = 'localhost';
$username = 'root';
$password = '';
$db = 'TNW';
$conn = mysqli_connect($server, $username, $password, $db);
if($conn){
$query = "DROP TABLE `username`";
$query_run = mysqli_query($conn, $query);
if($query_run){
echo 'Successfully deleted a table.';
}else{
echo 'Deleting a table Error.';
}
}else{
echo 'Connecting to a database Error.';
}
?>


ZilaStar ICT Jun 22 2019, 19:05:36

Creating table in a database

<?php
$server = 'localhost';
$username = 'root';
$password = '';
$db = 'TNW';
$conn = mysqli_connect($server, $username, $password, $db);
if($conn){
$query = "CREATE TABLE `username`(
UserId int(30) NOT NULL AUTO_INCREMENT PRIMARY KEY,
FirstName varchar(30) NOT NULL,
LastName varchar(30) NOT NULL,
UserName varchar(30) NOT NULL,
Password varchar(50) NOT NULL
)";
$query_run = mysqli_query($conn, $query);
if($query_run){
echo 'Successfully created a table.';
}else{
echo 'Creating a table Error.';
}
}else{
echo 'Connecting to a database Error.';
}
?>


ZilaStar ICT Jun 21 2019, 19:51:07

Connecting to a database

<?php
$server = 'localhost';
$username = 'root';
$password = '';
$db = 'TNW';
$conn = mysqli_connect($server, $username, $password, $db);
if($conn){
echo 'Successfully connected to a database -' .$db. '.';
}else{
echo 'Connecting to a database Error.';
}
?>


ZilaStar ICT Jun 20 2019, 18:43:43

Deleting a database

<?php
$server = 'localhost';
$user = 'root';
$password = '';
$conn = mysqli_connect($server, $user, $password);
if($conn){
$query = "DROP DATABASE `TNW`";
$query_run = mysqli_query($conn, $query);
if($query_run){
echo 'Successfully deleted a Database.';
}else{
echo 'Deleting a database Error.';
}
}else{
echo 'Connection Error';
}
?>


ZilaStar ICT Jun 19 2019, 18:34:54

Creating a database

<?php
$server = 'localhost';
$user = 'root';
$password = '';
$conn = mysqli_connect($server, $user, $password);
if($conn){
$query = "CREATE DATABASE `TNW`";
$query_run = mysqli_query($conn, $query);
if($query_run){
echo 'Successfully created a Database.';
}else{
echo 'Creating a database Error.';
}
}else{
echo 'Connection Error';
}
?>


ZilaStar ICT Jun 19 2019, 17:08:12

Connecting to database server in php

The following is the example of connecting to database server in php.

<?php
$server = 'localhost';
$user = 'root';
$password = '';
$conn = mysqli_connect($server, $user, $password);
if($conn){
echo 'Successfull connected to the server.';
}else{
echo 'Connection Error.';
}
?>


ZilaStar ICT Jun 18 2019, 21:44:35

Codes for file upload in php (step4)

We can set the limitations in uploading files. For example, we allow to upload only jpg or jpeg images and the maximum file size is 800KB.

<?php
@$name = $_FILES['file']['name'];
@$type = $_FILES['file']['type'];
@$size = $_FILES['file']['size'];

@$extension = substr($name, strpos($name, '.')+1);
@$max_size = 800000;

@$tmp_name = $_FILES['file']['tmp_name'];
@$location = 'tnw87/';


if(isset($name) && !empty($name)){
if($extension == 'jpg' || $extension == 'jpeg'){
 if($size < $max_size){
 if(move_uploaded_file($tmp_name, $location.$name)){
  echo 'Successfully uploaded!';
 }else{
  echo 'Upload Errors!';
 }
 }else{
  echo 'The maximum file size is 800KB';
 }
}else{
 echo 'Only jpg or jpeg image is allowed!';
}
}else{
 echo 'Please choose a file to upload';
}

?>

<form action = "upload.php" method = "POST" enctype = "multipart/form-data">
<input type = "file" name="file"><br /><br />
<input type = "submit" value = "Submit">
</form>


ZilaStar ICT Jun 18 2019, 11:23:14

Codes for file upload in php (step3)

In this example, we will upload file to the designated location. So, we will create a folder to store the files we've uploaded and give name to that folder. I give it as tnw87. Ok, lets start write the following codes and discover how it works.

<?php
 $name = $_FILES['file']['name'];
 $type = $_FILES['file']['type'];
 $size = $_FILES['file']['size'];
 $tmp_name = $_FILES['file']['tmp_name'];
 if(@isset($name) && @!empty($name)){
 $location = 'tnw87/';

 if(move_uploaded_file($tmp_name, $location.$name)){
  echo $name. ' is successfully uploaded.';
 }else{
  echo 'Upload Errors';
 }
 }else{
  echo 'Please select file to upload';
 }
 ?>

 <style type = "text/css">
 form{margin-top : 100px; margin-left : 50px;}
 </style>

 <form action = "upload.php" method = "POST" enctype = "multipart/form-data">
 <input type = "file" name = "file"></br></br>
 <input type = "submit" value = "Upload">
 </form>


ZilaStar ICT Jun 17 2019, 16:57:06

Codes for file upload in php (step2)

When we upload a file into one location, the file is firstly saved in temporary location as a temp file. Ok, lets discover how it works. We will write the following codes and test it.

<?php
$name = $_FILES['file']['name'];
 $type = $_FILES['file']['type'];
 $size = $_FILES['file']['size'];
 $tmp_name = $_FILES['file']['tmp_name'];
 if(@isset($name) && @!empty($name)){
 $location = 'tnw87/';
 if(move_uploaded_file($tmp_name, $location.$name)){
  echo $name. ' is successfully uploaded.';
 }else{
  echo 'Upload Errors';
 }
 }else{
  echo 'Please select file to upload';
 }
 ?>

 <style type = "text/css">
 form{margin-top : 100px; margin-left : 50px;}
 </style>

 <form action = "upload.php" method = "POST" enctype = "multipart/form-data">
 <input type = "file" name = "file"></br></br>
 <input type = "submit" value = "Upload">
 </form>


ZilaStar ICT Jun 16 2019, 16:53:46

Codes for file upload in php (step1)

<?php
 @$name = $_FILES['file']['name'];
 @$type = $_FILES['file']['type'];
 @$size = $_FILES['file']['size'];
 if(@isset($name) && @!empty($name)){
  echo 'File name is <strong> '.$name.'</strong>, File type is <strong>'.$type.'</strong> nad File size is <strong> '.$size.'</strong>';
 }else{
  echo 'Please select file to upload';
 }
?>

 <style type = "text/css">
 form{margin-top : 100px; margin-left : 50px;}
 </style>

 <form action = "upload.php" method = "POST" enctype = "multipart/form-data">
 <input type = "file" name = "file"></br></br>
 <input type = "submit" value = "Upload">
 </form>


ZilaStar ICT Jun 15 2019, 16:56:35

Timestamp in php

<?php
$time = time();
$time_now = date('D M Y & H:i:s', $time);
$time_modified = date ('D M Y @ H:i:s', strtotime('+ 1 year') );
echo 'The current time is '.$time_now.'.</br>The time modified is '.$time_modified.'.'  ;
?>


ZilaStar ICT Jun 14 2019, 16:54:14

Using header in php

<?php
$redirect_page = 'https://www.tnw87.com';
$redirect = true;
if($redirect == true){
  header('location:' .$redirect_page);
}
?>


Page : 17 of 30
To Contact
Available Services
Terms and Conditions