There are some certain ways to send your information or data to the PHP page-

  1. Using Form Methods – Get & Post
  2. Using Cookies & Session
  3. Using Query String / URL Rewriting
  4. Using Hidden form field

Form Methods             

The GET Method: The GET method sends information separated by the ? Operator.

Example: http://www.xyz.com/home.html?city=Gurgaon

Please note that the GET method is restricted to send upto 1024 characters (1024 bytes) only. You should not use GET method if you have password or other confidential information to be proceeding over the server.

GET can’t be used to send binary data, like images or word documents, to the server.

The PHP provides $_GET associative array or super global variable to access the data sent using GET method.

Example –GET Method:

Let’s create a HTML form that contain several form elements

HTML Page: form.html

<form action =”thanks.php” method=”GET”>

Enter Name : <input type=”text” name=”txtName”>

<input type=”submit” value=”Submit”>

</form>

Here we have a text field called txtName, basically we wanted to send the value of this field to the PHP page called thanks.php. Make sure your form should contain a button type submit to send information to action page.

Let’s create a page thanks.php in the same directory where we have the above html page

PHP Page: thanks.php

<?php

echo $_GET[‘txtName’];

?>

Meanwhile you can see the same entered value on the browser‘s address bar. Here we have print the same value received through text field named txtName. Make sure the same name to be put inside [ ] of super global variable $_GET as mentioned in HTML Form.

The POST Method

The POST method transfers information via HTTP headers.

The POST method does not have any restriction on data size to be sent. So it can be used to send files, images as well as binary data as well.

The PHP provides $_POST super global variable or associative array to access data sent using POST method.

Example –POST Method:

Let’s create a HTML form that contain several form elements

HTML Page: form.html

<form action =”thanks.php” method=”POST”>

Enter Email : <input type=”email” name=”email”>

Enter Password : <input type=”password” name=”pass”>

<input type=”submit” value=”Login”>

</form>

Here we have two fields email field called email, password field called pass, basically we wanted to send these above values to the PHP page called thanks.php

Let’s create a page thanks.php in the same directory where we have the above html page

PHP Page: thanks.php

<?php

echo $_POST[‘email];

echo $_POST[‘pass];

?>

Here we have print the same value received through email and password field respectively.

We can make it little advanced by taking above posted values to the variables. The advantage of using variable will be like we can use some validation and sanitizing data before preceding it to the database.

So the above code can be modified something like-

<?php

// collect values in the variables separately

$email= $_POST[‘email];

$password= $_POST[‘pass];

// you may use some validations like

if($email==”” || $password==””)

echo “Input required”;

else

echo “Welcome “.$email . “ Your password is “.$password;

?>

author image

About admin

You Might Also Like...

JavaScript – Advanced Learning
WordPress Training in gurgaon
PHP-Insert Data into Mariadb

10 Comments

  1. Благодаря вашему порталу, можно всегда оставаться в курсе самых последних новостей…

  2. Thanks for finalpy talking about >Datta Sending Wayss in PHP –
    Hirdesh Bhardwaj <Liked it!

  3. На этом ресурсе я нахожусь
    непродолжительное время!

    Я случайно наткнулся на этот
    портал, и нашел здесь много увлекательной информации;)
    Я обязательно порекомендую его всем своим друзьям!!!

  4. how to make money as a kid how to get rid of flying ants how to write an essay conclusion why do dogs eat grass reddit what will my baby
    look like in the future how to cook lobster tail steam
    how to make garlic bread from scratch what time is it in hawaii kauai right
    now how to last longer in bed tonight how long are dogs pregnant how to make paper
    flowers template when is daylight saving time in europe how many weeks pregnant am i
    test who viewed my facebook profile how to get rid of pimples on chest how to make rice crispy treats easy how to cook butternut squash on the grill how to deactivate facebook account how to stop hiccups for adults how old is earth
    whose number is this free with name how to cook broccoli rice how to write a
    check with cents what is a cv joint what movie should
    i watch right now how to cook that mini bakery when was
    jesus born date month and year how to make lasagna sauce what channel is abc on cox how
    to cancel amazon prime channel what animal am i most like how can you
    get rid of double chins how tall is justin bieber when he
    was 15 how to make an application letter what is an adjective prepositional phrase
    where the red fern grows audiobook how to cook bacon in the oven the kitchn does
    he like me quiz how many weeks am i who is winning the election for
    governor in california what celebrity do i look like app for android what does ad stand for on a timeline how to remove blackheads from nose how
    to make french toast without milk how to stop masturbating how
    long are dogs pregnant with puppies how old are you in 5th grade how old is blake shelton and gwen stefani
    who deleted me on facebook pantip how long does marijuana stay in your system how to
    make an app for free

  5. food to eat on orlistat, orlistat mechanism of action pdf http://orlistat.medinfoblog.com – orlistat has stopped working, 1,

  6. é mestre em pulos, proponho que, para festejar nosso acordo de amizade, me
    dê um curso de pulos, para eu ficar tão puladora como Uma boa selecção é conectar-se website da Associação Brasileira de Instrução a Distância ( ) que disponibiliza informações sobre essa nova forma de aprendizagem,
    agenda de informações, biblioteca virtual sobre instrução à distância e também um catálogo
    de cursos.

  7. Hello, i feel that i saw you visited my web site thus i came to go
    back the prefer?.I am attempting to find things to enhance my web site!I guess its ok to make
    use of a few of your ideas!!

  8. Pretty component to content. I simply stumbled upon your site and in accession capital to say that I get in fact enjoyed
    account your blog posts. Any way I will be subscribing on your augment or even I success you get entry to constantly
    rapidly.

  9. Have you ever thought about publishing an ebook
    or guest authoring on other blogs? I have a blog based on the
    same ideas you discuss and would love to have you share some stories/information. I know my viewers would
    value your work. If you are even remotely interested, feel
    free to shoot me an e-mail.

  10. I very lucky to find this site on bing, just what I was looking for :
    D besides saved to bookmarks.

Leave a Reply

Your email address will not be published.

Enjoy the tutorial? Please spread the word :)

Follow by Email
Facebook
Facebook
YouTube86
YouTube