Your variable will be created only after submitting the form. That is why in the code you need to make a check-up and only then show that variable. Try like this:
<?php
if(isset($_GET['username'])){
echo $_GET["username"];
}
?>
Your variable will be created only after submitting the form. That is why in the code you need to make a check-up and only then show that variable. Try like this:
<?php
if(isset($_GET['username'])){
echo $_GET["username"];
}
?>
<form action="site.php" method="get">
Name: <input type="text" name="username">
<input type="submit">
</form>
<?php
echo $_GET["username"]
?>
Notice: Undefined variable: name in C:xampphtdocsphplessonsindex.php on line 26
After filling in the answer will be displayed.
Object was not found!
Thank you in advance for every answer.
You have to first test that the form has been submitted. The first time the page loads, it wont have been submitted and $_GET[‘userbame”] will not exist.
Do or Do Not, there is no “Try” padawan. A
@RiggsFolly updated answer, added explanation.
Proper bracing and closing should be used also.
@FunkFortyNiner also added that.
@ElmanHuseynov I noticed 😉