Wednesday, 8 June 2011

PHP Form submission

                                          


          FORM SUBMISSION
------------------------------------------------------------------------------------------------------------

<form name="myfrm" id="myfrm" action="#" method="post">
<strong>username:</strong>
<input type="text" name="uname" id="uname" /><br/>
<strong>password:&nbsp;</strong>
<input type="password" name="pwd" id="pwd" /><br />
<br />
<input type="reset" value="refresh!!" />
<input type="submit" value="submit!!!" />
</form>

explanation:-
form:-attributes:-name,id,action,method,enctype.

action:-this means targeted file,or itself(#)

method:-get(default)/post:-it takes the data from the form

reset:-it refresh the form fields

submit:-it submit the form into targeted file.

process:-when u submit the button method take the form values ,after action
            attribute fire.

What is get?
1)data is sending through url is called get method.
2)the address bar (url) display the form data.
3)it does not provide security.
4)so it is not applicable for sensitive transactions. Like bank transactions (user name, password)
5)but it is fast .
6)it support only small amount of data action=string1.php
name:apparao
password:srinu
           
*in URL (or) address bar:string1.php?uname=apparao&pwd=srinu
suppose action=#
in url (or) address bar:-form1.php?uname=apparao&pwd=srinu

what is post?
1)data is sending through virtual directory is called post method.
2)data is submitting through secured manner is called post method.
3)it supports large amount of data.(unlimited)
4)it is for non-idempotent usages.(database).

GLOBLE VARIABLES:-
1) $_GET []
2) $_POST []
3) $_REQUEST []
4 $_COOKIE []
5) $_SESSION []
           
1)      $_GET[]:-
SYNTAX:-1)$_GET['variable'];
1) $_GET[] is used to receive the data from the form.
2) this accept only get() method//hint:-form

2)$_POST[]:-
syntax:-$_POST['variable']; 
 1)$_POST[] is used to receive the data from the form.
                         2)this accepts only post() method//hint:-form       ex:-form1.php
                                                                                                              formhandling.php

3)$_REQUEST[]:-
1)this is also used to receive the data from the form
2)this accepts both the methods get(),post()//hint:-form methods

Tuesday, 7 June 2011

PHP Strings

                                   

 
                          STRINGS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string:-collection of characters and words.

1)implode():-implode(",",array):-it will return the array with seperated ,
supposing i am giving * instead of , it will return the array with * seperator.

2)explode():-(" ",array)
            it will return where the space is there ,that is treated
an element,we should print index wise of the element.
//see example string4.php

3)str_repeat():-str_repeat("*=",10)//o/p *=*=*=up to 10 times

4)str-replace():-str_replace($string1," ","this is apparao");
it will return the first string and this is apparao ,first check the positions ,if first position in the string
and a is same
it doesnot print any thing ,and check second position 2 element
in the string and p is not same  then it will print p.like this way.

            (or)
str_replace("is","was",$string);
            it will replace was in the place of is in the string $string(****)

ereg_replace():-i am not understood this please verify once again.

*** strstr():-strstr($string,'needle');
            examle:-strstr($string,'@');
it will return after the @
apparao_katra@yahoo.com--->o/p @yahoo.com

strtok():-it will return the words.
substr():-it will return the substring . we have to give the positions to retrieve the substring

example:-1) substr('abcdef',1);o/p bcdef
                            2) substr('abcdef',1,3);//o/p bcd

ucfirst($string):-it will change the first char is capital

ucwords($stirng):-it will change every word first char is capital

wordwrap():-wordwrap($text, 20,"<br>");
it return every 20 chars break.

strlen():-it will return the length of the string.

stristr(string,'char'):-it will return the from that char on wards.
            $email = 'USER@EXAMPLE.com';
 echo stristr($email, 'e');
// outputs ER@EXAMPLE.com

strrev(string):-it will return the string from back.

strtolower(string):-it will return the string into small case.

strtoupper(string):-ir will return the string into upper case.
//see string16.php ***********

strripos($string,$needle):-it will return the position of the needle




Visual comparison of the two methods, creating a simple table.

Option 1, using PHP: // PHP $html = '<table>' ;     foreach ( $data as $row ) {     $html .= '<tr>...