on Sunday, November 11, 2012

Mysql Insert using form

For creating dynamic pages it is so important to know how data is inserted in mysql data base.

Example --à

// save as form.php or form.html
<html>
<head><title>connection through form action</title></head>
<body>
<form action=”insert.php” method=”POST”>
 //here we can use method=”GET”
//GET is use for passing variables through address bar whereas POST method doesn’t show         any pass in url or address bar.
// form fields like input box and buttons etc...
<input type=”text” id=”name” name=”name” />
<input type=”text” id=”age” name=”age” />
</form>
</body>
</html>

MySql DB connection

Now I am going to tell You how to stabilise a connection with DB.
Syntax:             
mysql_connect(nameofserver,username,password);

Exapmle

mysql_connect(“localhost”,”root”,””) or die (“not connected”);
// localhost is use for local server
You can do it by other way also
$myhost=”localhost”;
$username=”root”;
$password=””;
mysql_connect($host,$username,$password) or die (“not connected”);

NOW , How to connect with database

Syntax:
First stabilise  the connection with server
mysql_connect(“localhost”,”root”,””) or die (“not connected”);
mysql_select_db(“myDb”) or die(“db not connected”); 

POST:

‘POST’ is used for the value sending . the values sent that aren’t  appears in url bar.Generally used for login and security.

Here I am going to give an example try it.
// save the below given as “test.php”

<!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=utf-8" />
<title>my post method</title>
</head>

<body>
<form action="action.php" method="post" name="passing value by post">
<label>Enter Name</label>&nbsp; :<input name="name" type="text" />
<br />
<label> Enter Age</label>&nbsp; :<input name="age" type="text" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
on Thursday, November 8, 2012

GET

‘GET’ is used for the value sending . the values sent that are appears in url bar.
Here I am going to give an example try it.

// save the below given as “test.php”

<!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=utf-8" />
<title>my Get method</title>
</head>

<body>
<form action="action.php" method="get" name="passing value by get">
<label>Enter Name</label>&nbsp; :<input name="name" type="text" />
<br />
<label> Enter Age</label>&nbsp; :<input name="age" type="text" />
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>

Functions

The beautiful of PHP is the functions of PHP. Come to the types of functions ,
Types of PHP functions, we dividing here

1)User Defined functions
2)PHP In-built Functions.
                a) frequently used functions
                b) less-frequently used functions

1)User Defined Functions
  You can defined your function according to your use

Syntax:
// without passing argument
function  myfunction()
{
echo “hello , I am in function without arguments”;
}
myfunction();     // calling the function
Outut :
Hello , I am in function without arguments

for-each loop

Some of us have the question that why we use for-each when we have already for loop.
So that the answer is for-each loop is used for the array, but how?

Coming to the Syntax:
foreach($arrayname as $value)
{
// code for execution
}
EXAMPLE
$myname=array(“softfive”,”soft”)
foreach($myname as $value)
{
echo $value.” , “;
}
Output
Softfive , soft

on Saturday, November 3, 2012

PHP Loops

Loops having a great importance in any language.
      1)    If-else loop:-
If-else loop used for the condition checking if condition is true then if executed otherwise else executed
Example shown below-
// loop starts
If (condition)
{
}
else
{
}

PHP Variables

A PHP variable starts with sign ‘$’ and variable name contains only
 ( _  , a-z , A-Z , 0-9 ).
(Note: PHP is a case sensitive. ‘a’ and ‘A’ are different names and don’t use spaces in variable name)
Some examples of variables are:-
$myname=”softfive”;
$_myname=”softfive”;
$1=”softfive”;

<html>
<head></head>
<body>

PHP Basics

Before starting PHP you should know about HTML ,scripting and the basics of PHP.
Example of PHP application is www.facebook.com .

Now coming to topic,

The first question arises in your mind what is PHP and PHP stands for What?
The answer is PHP HYPERTEXT PREPROCESSOR .

PHP is server side scripting language i.e. you need a server to run the PHP code.

Now the questions comes to extension of PHP,
The extension of PHP are .phtml , .php , .php3.
You can use any of above three for PHP.

When you are concerning with web application then you should aware with the presentation of web pages that uses HTML for the presentation.
Placement papers (Free Download Here)

IBM Papers

sample 1 sample 2 sample 3 sample 4

INFOSYS Papers

sample 1  sample 2  sample 3 sample 4

Note: there are mainly two rounds in Infosys first is aptitude and second is HR . Aptitude round contains two section English and quantative &amp; reasoning. If  you are not qualify in English section then your quantative section will not consider.