I am just starting out in PHP/Html web development. I have a basic page with a username and password field and a submit button. I want to get the data from the username and password boxes into the php.
Here is my code...
<html>
<head>
<title>PAGE TITLE</title>
</head>
<body>
<h1 align = "center">Harro</h2>
<form align = "center">
Username: <input type="text" name="firstname"> <br>
Password: <input type="password" name="pwd"> <br>
<input type="submit" value="Enter">
<?php
???
?>
</form>
</body>
Specify the URI of the PHP program the form should be submitted to using the action
attribute.
<form action="foo.php">
Then, when the form is submitted, PHP will populate the $_GET
or $_POST
superglobal with the data.
add name attribute in submit button eg: name="submit"
And
add attribute in form tag method="post"
and write php code at top
<?php
if(isset($_POST['submit'])){
echo "USERNAME ".$_POST['firstname'];
echo "PASSWORD ". $_POST['pwd'];
}
?>
What you want is learning to code PHP web-apps from ground-up.
Currently what you will get from answers is just the code to get the Username
and Password
from the user. But the main thing comes after that. Like validation, and checking the login information from the database and then retrieving it.
Personally, I would recommend you to read O'Reilly Media's Learning PHP, MySQL, JavaScript, and CSS.