The most viewed posts

Registry Reviver

Web Development Services

Contact Me

How to clean up Windows Computer

About Desktop Icons in Windows Computer

Driver Booster

Computer Repair and Maintenance Service

CCleaner

How to make a computer secure and run faster

Myanmar font and keyboard for Windows

The most viewed items

Dell Inspiron 5559

Desktop Hard Disk

Laptop RAM

SONY Playstation Portable

HP ProBook 430

External Hard Disk

Laptop

Please login to start chat

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);
}
?>

ZilaStar ICT Jun 14 2019, 13:09:33

Search and replace in php


<?php
$offset = 0;

if(isset($_POST['text']) && isset($_POST['search']) && isset($_POST['replace'])){
 $text = $_POST['text'];
 $search = $_POST['search'];
 $replace = $_POST['replace'];

 $search_length = strlen($search);
 
 if(!empty($text) && !empty($search) && !empty($replace)){
   while($strpos = strpos($text, $search, $offset)){
   $offset = $strpos + $search_length;
   $text = substr_replace($text, $replace, $strpos, $search_length);
   echo $text;
   }
 }else{
   echo 'Please fill all fields!';
 }
}
?>

<hr />
<form action="searchandreplace.php" method="POST">
<textarea name="text" rows="15" cols="60"></textarea><br /><br />
Search : </br>
<input type="text" name="search"><br /><br />
Replace : </br>
<input type="text" name="replace"><br /><br />
<input type="submit" value="Submit">
</form>

ZilaStar ICT Jun 13 2019, 13:07:01

Similarity in php

<?php
$string = 'Hi, this is the php testing!';
$string1 = 'Hi, this is string testing!';
similar_text($string, $string1, $result);
echo $result;
?>

ZilaStar ICT Jun 12 2019, 16:54:42

Wordcensoring in php

From the following example, you can learn the usage of form, textarea, isset, strtolower and str_replace. Every word 'love' you type in the text box, the codes will change with the word 'hate'.

<?php
$find = 'love';
$replace = 'hate';
if(isset($_POST['user_input']) && !empty($_POST['user_input'])){
   $user_input = strtolower($_POST['user_input']);
   $user_input_new = str_replace($find, $replace, $user_input);
   echo $user_input_new.'</br>';
}else{
  echo 'Please fill in the text box!';
}
?>

<form action = "wordcensoring.php" method = "POST">
<textarea name = "user_input" cols = "40" widths = "500"></textarea></br></br>
<input type = "submit" value = "Submit">
</form>

ZilaStar ICT Jun 12 2019, 12:15:54

Array in php

 Normally There are three types of array: Indexed Array, Associative Array and Multi-Dimentional Array.

1. Indexed Array (Works with number)

<?php
$snack = array('Banana', 'Ice-cream', 'Coconet', 'Mango', 'Orange');
$snack[1]='Alcohol';
echo $snack[1];
//print_r($snack);
?>
 

 2. Associative Array (Works with name)

<?php
$snack = array('Banana' => 100, 'Apple' => 200, 'Cake' => 300);
echo 'The cake is '.$snack['Cake']. ' Kyat.';
?>


3. Multi-Dimentional Array

<?php
$food = array('Healthy'=>array('Salad'=>200, 'Milk'=>100, 'Coconet'=>200),
              'Unhealthy'=>array('Alcohol'=>200, 'Beer'=>300));

foreach($food as $element => $inner_array){
  echo '<br /><strong>'.$element.'</strong><br />';
  foreach($inner_array as $inner_element => $item){
    echo $inner_element.' = '.$item.'<br />';
  }
}
?>

 

ZilaStar ICT Jun 11 2019, 12:15:54

Matching with function in php


<?php
$string = 'I am Thet Naing Win and who are you?';
$find = '/000/';

function Match($find, $string){
  if(preg_match($find, $string)){
   return true;
  }else{
   return false;
  }
}

if(Match($find, $string)){
  echo 'Match Found!';
}else{
  echo 'Match Not Found!';
}
?>

ZilaStar ICT Jun 11 2019, 11:43:27

Matching in php

<?php
$string = 'Hi How are you?. I am Thet Naing Win. Nice to meet you!';
$find = '/000/';
if (preg_match($find, $string)){
  echo 'Match Found!';
}else{
  echo 'Match Not Found!';
}
?>

ZilaStar ICT Jun 11 2019, 13:18:59

Randomization in php

<?php
if(isset($_POST['roll'])){
 $rand = rand(000, 999);
 echo 'You rolled a '.$rand.'.';
}
?>

<form action = "rand.php" method = "POST">
<input type = "submit" name = "roll" value = "Roll a Dice">
</form>

ZilaStar ICT Jun 11 2019, 13:10:22

Using html form in php

<?php
 if(isset($_POST["username"]) && isset($_POST["password"])){
  $username = $_POST["username"];
  $password = $_POST["password"];

  if(!empty($username) && !empty($password)){
   echo 'Welcome to TNW, '.$username.'!';
  }else{
   echo 'Fill in all fields!';
  }
 }
?>

<form action = "test.php" method = "POST">
 Username:<br />
 <input type = "text" name = "username"><br /><br />
 Password:<br />
 <input type = "password" name = "password"><br /><br />
 <input type = "submit" value = "Log In">
</form>

ZilaStar ICT Jun 10 2019, 14:54:47

Function with return value in php

<?php
function Add($num1, $num2){
$result = $num1 + $num2;
return $result;
}

function Divide($num1, $num2){
  $result = $num1/$num2;
  return $result;
}
$info = Add(Add(5,5), Divide(4,2));
echo $info;
?>

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