> May 2013 ~ Online tutorial

How do get month using javascript

How do Get month using javascript

In the java script we can using getMonth() function which is used to get current month.

Program



<html>
<body>
<script type="text/javascript">
d=new Date();
ch=d.getMonth();
document.write(ch);
</script>
</body>
<html>
Output:


In this program The program will return only numeric value if it is 2 then month is march so you can using this is coding you can find current month.

Pop up box in javascript

Pop up box in java script

In this below coding is used to show How do create popup box using javascript.
Alert box:In this type of pop up box some message will be displayed
confirm box:In this type of popup box in which message about confimation will be displayed
Prompt boxIn is a type of popup box which display text window in which user can enter something Hence it has two buttons OK or cancel




Program


<html>
<body>
<script type="text/javascript">
if(confirm("do you agrred?"))
alert("You have agreed");
else
input_text=prompt("Enter some string here," ");
alert("hi"+input_text);
</script>
</body>
</html>





make image using php

make image using php

In this program we will create image using php.In the imagecreate is used to create the image space.


<?php
header("Content-Type: image/png");

$im = @imagecreate(500, 120)

or die("Cannot Initialize new GD image stream");

$background_color = imagecolorallocate($im, 0, 0, 0);

$text_color = imagecolorallocate($im, 233, 14, 91);

imagestring($im, 1, 10, 10, "Online tutorial", $text_color);

imagepng($im);

imagedestroy($im);

?>
Output

generate random in php


generate random in php

In this program is used generate random number in PHP.we are using rand() used to generate random number in PHP.


<?php
echo rand() . "\n";
echo rand(10,4);
?>





Upload file using PHP

Upload file using PHP

HTML Coding

In this example .i will show How upload file using PHP.we are two program here.one is HTM and PHP program.

In the HTML file get the file and send to the PHP program using POST method.


<html>
<body>
<form action="upload.php" enctype="multipart/form-data" method="post">
Select the file to upload<input name="upload" type="file" />
</form>
</body>
</html>

PHP Coding


<?php
$uploadddr='upload/';
$uploadfile=$uploaddr.basename($_FILE[''file']['name']);
if(move_uploaded_file($_FILE['file']['tmp_name'].$uploadfile))
{
echo "file is valid";
}
else
{
echo "file uploading failed";
}?>


PHP Program Explaination:

In the PHP program will get the file stored in file called upload.You must create upload folder in your Computer.

get Http vs Https in php

get Http vs Https in php

In this post. I will show you How do know your server protocol that is Http or https using PHP.
Coding



<?php

if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'
    || $_SERVER['SERVER_PORT'] == 443) {

  // HTTPS
echo 'https';
} else {

echo 'http';  // HTTP

}
?>

Output:

Getting image width and height using PHP

Getting image width and height using PHP

In Coding we are getting size of image using function getimagesize. it is get width and height of given object.


Coding


<?php

  list($width, $height, $type, $attr) = getimagesize("C:\wamp\www\Batista.jpg");

  echo "Image width <br/>" . $width."<br/>";
  echo "Image height <br/>" . $height."<br/>";
  echo "Image type <br/>" . $type."<br/>";
  echo "Attribute <br/>" . $attr."<br/>";

?>

Output





Get ip address using php

Get ip address using php

This tutorial i will show you get the IP(Internet Protocol)Address of proxy server.

Coding


<?php
if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
     $ip=$_SERVER['HTTP_CLIENT_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
     $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
     $ip=$_SERVER['REMOTE_ADDR'];
echo $ip;
}
?>

Program Explaination:

In this coding the REMOTE_ADDR will finding IP address of proxy server.

Output:




How do finding metatag using PHP

How do finding metatag using PHP:
This tutorial i will show  how do find the metatag of website using PHP. They function called get_meta_tags Which is used to get information of meta tag in the website.


Coding


<?php $tags = get_meta_tags("http://www.w3schools.com"); ?>


<h2>Author</h2>

<?php echo $tags['author']; ?> <br/>      // name 

<h2>Keywords</h2>

<?php echo $tags['keywords']; ?>   </br>  // php documentation

<h2>Description </h2>

<?php echo $tags['description']; ?> </br> // a php manual




Program Explain:


In this Program you finding the meta tag in the website.here  get_meta_tags which used get metatag information you can specific any site here.s

Output:

compare two number without using relational operator in c

#include<stdio.h>
#include<conio.h>
int main () {
{
int a,b;
printf ( "enter the two values u like to compare\n");
scanf (" %d %d",&a,&b);

if (!(a ^ b))

// ^ is Xor operator.
Xor operator function below


valuesvlauesOutput
000
011
101
110


printf ("both are equal\n");
else
printf ("both are not equal\n");
}

Output
Enter the value
10
15
Both are not equals