PHP Form Get Method With Source Code Example

PHP Form Get Method With Source Code Example mytechlearns
PHPLeave a Comment on PHP Form Get Method With Source Code Example

PHP Form Get Method With Source Code Example

PHP Form Get Method With Source Code Example

In software development using php, Get Method is very popular name and easily to use and handle data. When we pass data from one page to another page we can use get method. In this way, user also show all the data which passing in the get method. It shows user browser. But this is not a secure way to passing data from onek page to another page. Because of easiest it use most of the time. Let’s show how can pass data using get method:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Form Data Save Using PHP Get Method Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
  <h2 class="text-center">Bootstrap Form Data Save Using PHP Get Method</h2>
  <form class="form-horizontal" id="" name="" action="show.php" method="get">

    <div class="form-group">
      <label class="control-label col-sm-2" for="name">Full Name:</label>
      <div class="col-sm-10">
        <input type="name" class="form-control" id="name" placeholder="Enter Your Name" name="name">
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-sm-2" for="phone">Phone:</label>
      <div class="col-sm-10">
        <input type="phone" class="form-control" id="phone" placeholder="Enter Phone Number" name="phone">
      </div>
    </div>

    <div class="form-group">
      <label class="control-label col-sm-2" for="dept">Department:</label>
      <div class="col-sm-10">
        <select type="text" id="dept" class="form-control" name="dept"> 
        	<option selected value="">Select Your Department</option> 
            <option value="mytechlearns.com">My Tech Learns</option> 
            <option value="BBA">BBA</option> 
            <option value="CSE">CSE</option> 
            <option value="EEE">EEE</option> 
        </select>
      </div>
    </div>

    <div class="form-group">        
      <div class="col-sm-offset-2 col-sm-10">
        <button type="submit" value="submit" id="submit" class="btn btn-default">Submit</button>
      </div>
    </div>
  </form>
</div>

</body>
</html>

In this page, when user submit button press then all the name tag value pass the another page show.php. Have a look this page:

<html>
<head>
	<title>PHP Get data receive and show</title>
</head>
<body>
	<?php 
		$name = $_GET['name'];
		$phone = $_GET['phone'];
		$dept = $_GET['dept'];
	?>

	<h2>Full Name: <?php echo $name; ?></h2>
	<h3>Phone Number: <?php echo $phone; ?></h3>
	<h3>Department: <?php echo $dept; ?></h3>
</body>
</html>

Get all the value in this page and echo using to show all this value.

That’s all for today. Happy Coding….

Source Code: Click Here

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top