Welcome

All in one resource for most usable codes in programming in PHP, HTML, JS, CSS.

stackMyCode

All in one resource for most usable codes in programming in PHP, HTML, JS, CSS.

New Technology

We are providing you the most newable resh technologies for you.

Tech News

stackMyCode is allways looking for tech news in computer world. If we found a good news stackMyCode will update you with Tech news.

Monday, November 11, 2013

How to get thumbnails from youtube video

Get thumbnails from youtube video


If you are developing youtube video integrated own video site with video thumbnails or do you want list some youtube videos with video thumbnails you can use this script with php and json

Use the data on server-side using PHP

<?php

$json = json_decode(file_get_contents("http://gdata.youtube.com/feeds/api/videos/<youtube-video-id-here>?v=2&alt=jsonc"));
echo '<img src="' . $json->data->thumbnail->sqDefault . '">';

?>



Replace <youtube-video-id-here> with your youtube video IDs.

Sunday, October 27, 2013

php tag

There are two types tag we used.

1.Canonical PHP tags:


The most universally effective PHP tag style is:

<?php...?>

2.Short-open (SGML-style)


tags: Short or short-open tags look like this:

<?...?>

Saturday, October 26, 2013

PHP Hellow world Programme

PHP Hello world script

PHP is embedded in HTML. That means that in amongst your normal HTML.

<html> 
<head> 

<title>Hello World</title> 

<body> 

<?php echo "Hello, World!";?> 

</body> 
</html>

why we are using php?

Usages of PHP


  • Perform to system functions
    • create files
    • open files
    • read files
    • write files and close files
  • Handle the data bases through PHP
  • PHP can encrypt data.
  • PHP can handle forms.
  • We can create cookies and  set cookies variables using PHP
  • PHP can use to restrict or prevent some website pages from web site users

php Introduction

What is PHP ?


PHP started out as a small open source project. But now it is using every where. Originally created by Rasmus Lerdorf in 1995.

  • PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
  • PHP is a sever side scripting language.
  • PHP is embedded in HTML
  • PHP is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.
  • PHP supports a large number of major protocols such as POP3, IMAP, and LDAP.
  • PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
  • PHP has list of syntax like C.

Friday, October 25, 2013

Input box glowing border effect with CSS

Hi friends,
So many web sites you are browsing can see new glowing border effect on where you entering text input boxes on forms such as login form, contact form or subscription form etc.  You can see this effect real time at twitter home page  https://twitter.com/

CSS glow effects with box shadow


stackMyCode will gives you CSS code for CSS glow effect in green color.

.shadowglow {
    outline:none;
    transition: all 0.25s ease-in-out;
    -webkit-transition: all 0.25s ease-in-out;
    -moz-transition: all 0.25s ease-in-out;
    border-radius:8px;
    -webkit-border-radius:8px;
    -moz-border-radius:8px;
    border:1px solid rgba(0,0,0, 0.2);
}

.shadowglow:focus {
    box-shadow: 0 0 5px rgba(0, 255, 0, 1);

    -webkit-box-shadow: 0 0 5px rgba(0, 255, 0, 1); 

    -moz-box-shadow: 0 0 5px rgba(0, 255, 0, 1);

    border:1px solid rgba(0,255,0, 0.8); 

}

Your input boxes class must use as shadowglow Example input box code is here :

<input class="shadowglow" id="textinput" name="textinput" type="text" />

Notepad++ - Notepad plus plus free download


Notepad++

Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.

Based on the powerful editing component Scintilla, Notepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.

Features

  1. Syntax Highlighting and Syntax Folding
  2. User Defined Syntax Highlighting and Folding: screenshot 1, screenshot 2, screenshot 3 and screenshot 4
  3. PCRE (Perl Compatible Regular Expression) Search/Replace
  4. GUI entirely customizable: minimalist, tab with close button, multi-line tab, vertical tab and vertical document list
  5. Document Map
  6. Auto-completion: Word completion, Function completion and  Function parameters hint
  7. Multi-Document (Tab interface)
  8. Multi-View
  9. WYSIWYG (Printing)
  10. Zoom in and zoom out
  11. Multi-Language environment supported
  12. Bookmark
  13. Launch with different arguments
 

What is HTML

HTML is a language for describing web pages.

  1.     HTML stands for Hyper Text Markup Language.
  2.     HTML is a markup language, not a programming language.
  3.     A markup language is a set of markup tags for markup content.
  4.     HTML tags describe document content
  5.     HTML documents contain HTML tags and plain text
  6.     Files saving extension is .html
  7.     User doesn't see the HTML tags and browser markup the web page using HTML tags
 
HTML Document sample source is below.
 
<!DOCTYPE html>

<html>

<body>

 

<h1>stackMyCode web title</h1>

 

<p>This is the paragraph.</p>

 
</body>

</html>

PHP - if Statement

This is a conditional statement on PHP.

Some tells you like this "If you work hard you can become 1st"

What will done if you work hard? You can become 1st.

PHP If statement is most suitable to it.

PHP "if" Syntax is below

if (condition)
  {
  code to be executed if condition is true;
  }

The example below will output "Hi, Good Morning!" if the current time (HOUR) is less than 12

We can get current time in hour using  date() function.

<?php

$time_in_hour=date("H");

if ($time_in_hour<"12")

  {

  echo "Hi, Good Moring!";

  }

?> 

Very Simple File Upload Script on PHP

Very Simple File Upload Script on PHP


Note : This php script is base on php file uploading only there are not security features.

We need two files. 1st one is for generate form. It can name as "uploadform.html"

<html>
<body>
<form action="uploadfile.php" method="post"

enctype="multipart/form-data">

<label for="file">Filename:</label>

<input type="file" name="file" id="file"><br>

<input type="submit" name="submit" value="Submit">

</form>

</body>
</html> 

2nd one is for handle uploaded file on web sever save and ect...

It can name as "uploadfile.php"

<?php
$file_saving_path = "upload_directory/";

$file_saving_path = $file_saving_path . basename( $_FILES['file']['name']); 

if(move_uploaded_file($_FILES['file']['tmp_name'], $file_saving_path)) 
{
echo "The file ".  basename( $_FILES['file']['name']). " has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
} ?> 

Thursday, October 24, 2013

Prevent direct access to a php include file

Prevent direct access to a php include file


This is the way to prevent direct access to a php include file on web host.

place following code on top of the base file:

like there is a form.php and you  need to include it on register.php (you need to write include('form.php') code on regidter.php file)

The Bas file is "register.php"

<?php

define('MyConst', TRUE);

?>

and you need to place following php code on top of the includable file (form.php) :

<?php

if(!defined('MyConst')) {

die('Direct access not permitted');

}
?>

Getting time and date from timestamp on php

Usually we record date and time date on MySQL table as timestamp  Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

It's like 1171502725

But we can read date time another date from it directly.

You can use following PHP Script to Get Date and Tme from time stamp on PHP

<? php

$date = date('d-m-Y', $timestamp);
$time = date('Gi.s', $timestamp);

?>
Date is
 <?=$date;?> <br/>
Time is
 <?=$time;?> <br/>

How to make a jpg image downloadale like a hyper linked file?

If you use the standard html link code for download JPG image file browser will open JPG file on browser. You can use php file to make JPG image file downloadable.

 
<a href="download-location/images/imagefile.jpg">download this picture</a> 
This will not work

You can use following code on php file name like imagedownloader.php

<?php 

// Force download of image file specified in URL query string and which 

// is in the same directory as this script: 

if(!empty($_GET['file'])) 

{ 

$filename = basename($_GET['img']); // don't accept other directories 

$size = @getimagesize($filename); 

$fp = @fopen($filename, "rb"); 

if ($size && $fp) 

{ 

header("Content-type: {$size['mime']}"); 

header("Content-Length: " . filesize($filename)); 

header("Content-Disposition: attachment; filename=$filename"); 

header('Content-Transfer-Encoding: binary'); 

header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 

fpassthru($fp); 

exit; 

} 

} 

header("HTTP/1.0 404 Not Found"); 

?>


Use link HTML tag as following. Replace imagefile.jpg the file as you wish to download

<img src="/download-location/images/imagedownloader.php?file=imagefile.jpg" alt="DownloadableImageLink">

How to get server domain name on php

How to get server domain name on php


Think, there is a php script on http://example-domain.com/loging/register.php If you need get web site only domain on register.php file. You can use following php code for get server domain name on php

 $serverPath='http://'.$_SERVER['SERVER_NAME'];

Note this is only for web site using http:// protocol
If your web site using https:// protocol use following php code

 $serverPath='https://'.$_SERVER['SERVER_NAME'];

How to embed a PHP file on Blogger

Hello today I'm going to tell you how embed a PHP file on blogger. With embedding a php file you can add php contact forms and php clocks and another php gadgets to your blog.

Now look how to do it.

Step 01 :

 Login to blogger dashboard  and click  on your blog  and click Layout on left side menu bar


Step 02 :

Click on 'Add a Gadget' where you want.


Step 03:


Select 'HTML/Javascript' and add the code given below and click save button.

<object width="400" height="300" type="text/html" data="file-url.php"></object>

Please Note that : You should replace "file-url.php" in data="file-url.php" attribute as your own php file.

How to get Current full URL on PHP

If you want to get current page url to do some thing, like if you embed the facebook social comment plugin on dynamic web site you want to declare the comment box commenting url. As this moment you want to get your current page URL dynamically.

You can use following php code to get current url

<?=$current_full_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";?>

this code will echo the current full url

PHP Introduction

Hello my friends,
Today I'm going to introduce something about php to you...

PHP what is PHP?

Mainly we can describe PHP as PHP: Hypertext Preprocessor
PhP is a server side scripting language like ASP but PhP mainly Use to Open source web developing...
PhP is supported to so many Database types like MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.
Happy to say You can download PHP for free at www.php.net
and PHP is an Open source Software...

PHP can ude with HTML and The extension of  php file is basically ".php"

if you iterested in PHP download and install php with XAMPP

This Post Source is my own another blog Sri Tech Masters Gang. It is a mix blog all about.
My Old Post is here:  http://srimasters.blogspot.com/2012/08/php-introduction.html