Get data From Html Form using PHP

Advertisements

Connect PHP Code with DataBase PHP Create Database MySQL

How to Get data From Html Form using PHP

For get data from from Html form you need $_POST function. First create one variable and pass filename in $_POST[] as a argument.

Syntax

$variable_name = $_POST["field_name"];

Example

<form action="" method="post">
Username: <input type="text" name="username" placeholder="username"><br>
Password: <input type="password" name="password" placeholder="password"><br>
<button type="submit" value="submit">Submit</button>
</form>

Using above Html page you can fill your data in textfile, this is html file after doing this process we create new php file and get Html form data on php page using $_POST function and store this data in $name and $pass variable. because on Html page we are using post method so use $_POST function. At last print value on web page using echo " ";

Get Html textfield data using PHP

<?php
$name = $_POST["username"];
$pass = $_POST["password"];

echo $name."</br>";
echo $pass."</br>";

?>

Output

Hitesh
123

Live Demo

Username:
Password:

Your Outpur After Running code




Connect PHP Code with DataBase PHP Create Database MySQL

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements