Local Bloggers

Hi In this blog i will provide educational help ,Jobs,Social Media Tricks and Tips.

Breaking

PropellerAds
Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Tuesday 23 January 2018

January 23, 2018

Difference Between $_GET AND $_POST global variables in php

Difference Between GET and POST method form in php

PHP(Pre Processor Hypertext) used many global variables in their program
but the two global variables are use at the same time some of students confuse
during use of GET or POST method in html form.
Todays Article is much important why we use GET method in HTML form
and why we use POST method in HTML form.

First and foremost thing is why we use this Global Variables
When we retrieve data from html form we use some back end languages
and this article about PHP so we give the name of input of html
than we write a syntax in php field like

CODE
GET METHOD
<html>
<head>
<title></title>
</head>
<body>
<form  method="GET" action="one.php">
<table>
<tr><td>Student ID</td> <td> <input type="input" name="a"></td></tr>
</table>
<input type="submit" name="submit">
</form>
</body>
</html>
<input>

<?php
//declare a variable name not same its just e..g just write the name of input

$Get=$_GET['a'];
//$_GET  shows a data in your URL bar after clicking submit
//
?>

POST METHOD

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form  method="POST" action="one.php">
<table>
<tr>
<td>Student ID</td>  <td> <input type="input" name="a"></td></tr>
</tr>
</table>
<input type="submit" name="submit">
</form>
</body>
</html>
<input>
<?php


//declare a variable name not same its just e..g just write the name of input

$post=$_POST['a'];

//$_POST not shows  data in your URL bar after clicking submit

//further details given


?>

POST METHOD

  • POST requests are not and never cached
  • POST requests do not copy in the browser history
  • POST requests cannot copy as bookmarked
  • POST requests have no restricted  data length
  • its data not show in url bar

GET METHOD

  • GET requests are cached
  • GET requests copy in the browser history
  • GET rquests  copy as bookmarked
  • GET method always use to fetch data (show user id ,student id)
  • Its data show on url's bar

Syntax 

$_GET['a'];
$_POST['a']

Wednesday 17 January 2018

January 17, 2018

How to insert data using php & MySql

How to insert data using php & MySql

Insert Value In Mysql using php form

Many ways to use Insert data using php in mysql database but today we discuss
Core Php method.It is a basic and easy way to learn php with mysql.
We just Create a HTML page and form.


Explanation 

  1. first we create a html page and save into htdocs as a index.php.
  2. Than create a connection with your database .
  3. Make two input field and one submit button.
  4. Write the accurate name of your inputs fields and PHP variables e.g $_POST['value1'].
  5. Than Run this code with connection .
  6. for connection check another article .



Html Form
<!DOCTYPE html>
<html>
<head>
   <title>Hello World</title>
        <style >
       
     </style>
</head>
<body>
<form method="post" action="index.php">
     <input type="text" name="value1">
     <input type="text" name="value2">
      <input type="submit" name="submit" Value="Ok!"> 

</form>
</body>

</html>





we get Post Values from (HTML FORM)

 if(isset ($_POST['submit'])){
  
  $a=$_POST['Value1'];
  $b=$_POST['Value2'];
  $q="INSERT INTO (TABLE NAME)  (col name1,col name2(in database)) VALUES('$a','$b')";
  $run=mysql_query($q);

}



col name: mean you should write name of your database column.
$a,$b,$q,$run: is variable its not necessary but its good habit to store every value in variable.


for any query about my post please comment here below.
Keep Visiting this blog for more helpful article.
Regards (haider ali uppal(software Engineer))