Tuesday, September 22, 2009
Define JavaScript? List advantages and disadvantages between java and JavaScript?
JavaScript is a compact, object-based scripting language for developing client Internet applications. It was designed to add interactivity to HTML pages. JavaScript is a scripting language - a scripting language is a lightweight programming language. A JavaScript is usually embedded directly in HTML pages. JavaScript is an interpreted language (means that scripts execute without preliminary compilation).Everyone can use JavaScript without purchasing a license. All major browsers, like Netscape and Internet Explorer, support JavaScript. JavaScript was developed by Netscape as Live Script - changed to JavaScript when endorsed by Sun 1993, version 1.0 released with Netscape 2.0. JavaScript is a powerful scripting language that is also capable of performing extensive form data collecting and form processing functions.
For instance, the following is an example of a complete script JavaScript tag:
Advantages of JavaScript
• Cross Browser supporting:
This means that the JavaScript codes are supported by various browsers like Internet Explorer, Netscape Navigator, and Mozilla etc.
• Platform Independent:
JavaScript codes can be executed in any platform like Linux, Microsoft Windows and many other operating systems.
• Lightweight for fast downloading:
The JavaScript codes runs directly in the client machine. The code should be downloaded all the way from server to the client and this time duration is very minimum and the executing the codes of JavaScript is also very fast.
• Validating Data:
The data can be validated in the two different ways:
Validating in server side or in server machine.
Validating in client side or in client machine.
In these two different types of validation of data the second one is much more faster, and this is done through JavaScript.
• Sophisticated User Interfaces:
By
using JavaScript you can create a user interactive interfaces that can
communicate with the user and the Browser.
• In-Built software:
To you don't need any extra tools to write JavaScript, any plain text or HTML editor will do, so there's no expensive development software to buy.
• Easy to Learn:
The JavaScript programmer should know the minimal syntax of JavaScript since it supports many syntax and data types as C and C++.
It's also an easy language to learn, and there's a thriving and supportive online community of JavaScript developers and information resources.
• Designed for programming User-Events:
JavaScript supports Object/Event based programming. So the code written in JavaScript can easily be break down into sub-modules.
Disadvantages of JavaScript:
• Launching an application on the client computer.
JavaScript is not used to create stand-alone application; it is only used to add some functionality in any web page.
• Reading or writing files:
JavaScript cannot read and write files into the client machines. It can only be used as a utility language to develop any web site.
• Retrieving the text contents of HTML pages or files from the server.
• Reading and Writing files to the server:
JavaScript can read and write to any file in the server as well.
• Sending secret e-mails from Web site visitors to you:
JavaScript cannot be used to send email to the visitors or user of the web site.
This can be done only with the server side scripting.
• Cannot create Database Application:
By using JavaScript you cannot connect the web site to the database. For this you need to use server-side scripting.
• Browser Compatibility Issues:
Not all browsers support the JavaScript codes. The browser may support JavaScript as a whole, but may not support the codes or lines of codes written in JavaScript and may interpret differently.
• JavaScript does not implement multiprocessing or multithreading.
• Use printers or other devices on the user's system or the client-side LAN.
• JavaScript has limitations of writing in a client machine. It can only write the cookie in client machine that is also of a certain size i.e. 4K.
What do you understand by CSS? Write the advantages of CSS?
Cascading Style Sheets, fondly referred to as CSS, is a simple design language intended to simplify the process of making web pages presentable. Cascading Style Sheets (CSS) is a style sheet language used to describe the presentation semantics (that is, the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can be applied to any kind of XML document, including SVG and XUL.
Flexibility-By combining CSS with the functionality of a Content Management System, a considerable amount of flexibility can be programmed into content submission forms. This allows a contributor, who may not be familiar or able to understand or edit CSS or HTML code to select the layout of an article or other page they are submitting on-the-fly, in the same form.
Page reformatting-With a simple change of one line, a different style sheet can be used for the same page. This has advantages for accessibility, as well as providing the ability to tailor a page or site to different target devices. Furthermore, devices not able to understand the styling will still display the content
Pages load faster –If we are using CSS, We do not need to write HTML tag attributes every time. Just write one CSS rule of a tag and apply to all the occurrences of that tag. So less code means faster download times. The overall saving in bandwidth is measurable. Since the style sheet is cached after the first request and can be reused for every page on the site, it doesn’t have to be downloaded with each web page. Removing all presentational markups from your web pages in favor of using CSS also reduces their size and bandwidth usage—by more than 50% in many documented cases. This benefits the site owner, through lower bandwidth and storage costs, as well as the site’s visitors, for whom the web pages load faster.
Easy maintenance –To make a global change, simply change the style, and all elements in all the web pages will be updated automatically. The positive impact this has onsite maintenance can’t be overestimated—editing one style sheet is obviously more efficient than editing 10,000 HTML files!
Multiple Device Compatibility –Style sheets allow content to be optimized for more than one type of device. By using the same HTML document, different versions of a website can be presented for handheld devices such as PDAs and cell phones or for printing. Separate styling rules can be used for different output media.
Global web standards –Now HTML attributes are being deprecated and it is being recommended to use CSS. So it’s a good idea to start using CSS in all the HTML pages to make them compatible to future browsers.
Thursday, August 27, 2009
Remove a running process from memory in DOS
Remove a running process from memory.
Syntax
KILL [option] process_id
KILL [option] task_name
KILL [option] window_title
Option
-f Force process kill
Note: Kill -f basically just nukes the process from existence, potentially leaking a lot of memory and losing any data that the process hadn't committed to disk yet. It is there for worst case scenarios - when you absolutely must end the process now, and don't care whether proper cleanup gets done or not.
Wednesday, August 19, 2009
how to find the model number of computer
wmic bios get serialnumber
2 To retrieve model name of the computer run the following command
wmic csproduct get name
3 Go to start / accessories /system tools / system information. Should bring up an info box with that info. .
4 Go to CPUID.com, and download a little program called CPU-Z. It'll tell you everything inside your computer plus the model no
Tuesday, August 11, 2009
content management system using php
A Content Management System ( CMS ) is used to add, edit, and delete content on a website. For a small website, such as this, adding and deleting a page manually is fairly simple. But for a large website with lots of pages like a news website adding a page manually without a content management system can be a headache.
A CMS is meant to ease the process of adding and modifying new content to a webpage. The pages content are stored in database, not in the file server.
This tutorial will present an example of a simple content management system. You will be able to add, edit and delete articles using HTML forms.
For the database table we'll call it the news table. It consist of three columns :
- id : The article's id
- title : The title of an article
- content : The article itself
First we need to create a script to add an article. It is just a form where a user can enter the article's title and content. <form method="post"> |
Now that we have the script to add articles let's create another script to view those articles. The script is list the title of articles available in database as clickable links. The article link have the article id appended like this One possible implementation of article1.php is presented below : |
With this implementation each article request involve one database query. For a heavy load website with lots of articles using the above implementation can cause a very high amount of database-request. So we need a better cms solution to reduce the load. |
First we need to specify the cache directory where all cache files are located. For this example the cache directory is located in the same place as the article2.php script. I mean if article2.php is stored in C:/webroot then the cache dir is in C:/webroot/cache/
The script thent check if the article was already in the cache. An article is saved into the cache directory using a filename generated from it's id. For example if you request the article using a link like this :
Then the cache file for the article is
_3.html
This filename is just an underscore ( _ ) followed by the article id. In case article2.php is called like this :
no id is defined so we make the cache file name as index.html
If the cache file is found , the content is read and printed using readfile() and the script terminate. When the article is not found in the cache then we need to look in the database and get the page content from there.
Example :
<?php
// ... previous code
if(!isset($_GET['id']))
{
$self = $_SERVER['PHP_SELF'];
$query = "SELECT id, title FROM news ORDER BY id";
$result = mysql_query($query) or die('Error : ' . mysql_error());
$content = '<ol>';
while($row = mysql_fetch_array($result, MYSQL_NUM))
{
list($id, $title) = $row;
$content .= "<li><a href=\"$self?id=$id\">$title</a></li>\r\n";
}
$content .= '</ol>';
$title = 'Available Articles';
} else {
// get the article info from database
$query = "SELECT title, content FROM news WHERE id=".$_GET['id'];
$result = mysql_query($query) or die('Error : ' . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$title = $row['title'];
$content = $row['content'];
}
include 'library/closedb.php';
// ... still more code coming
?>
As you can see above the process of fetching the article list and content is the same as article1.php. But before showing the page we have to start output buffering so we can save the content of the generated HTML file.
See the code below. Just before printing the html we callob_start() to activate output buffering. From this point no output is sent from the script to the browser. So in the code example below anything between <html> and </html> tag is not sent to the browser but stored in an internal buffer first.
After the closing html tag we useob_get_contents() to get the buffer content and store int in a temporary variable, $buffer. We then call ob_end_flush() which stop the output buffering ( so the page is now sent to the browser ).
Example :
<?php
// ... previous code
ob_start();
?>
<html>
// ... same html code as article1.php
</html>
<?php
// get the buffer
$buffer = ob_get_contents();
// end output buffering, the buffer content
// is sent to the client
ob_end_flush();
// now we create the cache file
$fp = fopen($cacheFile, "w");
fwrite($fp, $buffer);
fclose($fp);
?>
php code for login with javascript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>colors2web</title>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>colors2wweb login</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script language="javascript">
// Developed by pusp raj joshi
//
$(document).ready(function()
{
$("#login_form").submit(function()
{
//remove all the class add the messagebox classes and start fading
$("#msgbox").removeClass().addClass('messagebox').text('Checking User in colors2web database....').fadeIn(1000);
//check the username exists or not from ajax
$.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password').val() } ,function(data)
{
if(data=='yes') //if correct login detail
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('Logging in to the admin of colors2web.....').addClass('messageboxok').fadeTo(900,1,
function()
{
//redirect to secure page
document.location='main_login.php';
});
});
}
else
{
$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox
{
//add message and change the class of the box and start fading
$(this).html('You are not Administrator of colors2web...').addClass('messageboxerror').fadeTo(900,1);
});
}
});
return false; //not to post the form physically
});
//now call the ajax also focus move from
$("#password").blur(function()
{
$("#login_form").trigger('submit');
});
});
</script>
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: 24px}
-->
</style>
</head>
<body>
<?php include('header.php');?>
<form method="post" action="" id="login_form">
<table width="511" height="188" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#0099FF">
<tr>
<td height="32" colspan="2"><div align="center">AGENT LOGIN </div></td>
</tr>
<tr>
<td width="70" height="32">Username </td>
<td width="583" height="32"><label>
<input type="text" name="username" id="username"/>
</label> </td>
</tr>
<tr>
<td height="32">Password</td>
<td height="32"><label>
<input type="Password" name="password" id="password"/>
</label></td>
</tr>
<tr>
<td height="39"><label></label></td>
<td align="left" valign="bottom">
<div align="left">
<input name="Submit" type="submit" class="button" value=" login" style="margin-left:-10px; height:29px" />
<span id="msgbox" style="display:none"/>
</div></td></tr>
<tr>
<td height="23" colspan="2" align="center" valign="middle">Copyright © 2009 colors2web.Com All rights reserved. </td>
</tr>
</table>
</form>
</body>
</html>
Sunday, August 9, 2009
connection to database
$host = "localhost";
$user = "root";
$pass = "";
$conn = mysql_connect($host, $user, $pass);
$db=mysql_select_db('colors2web') or die(mysql_error());
?>