I am trying to concatenate the values of 2 fields when the user presses the button. After pressing the button it should display the concatenated string. Can't seem to figure this out as this is my first time playing with html forms. Here's my code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<form method="GET">
<input type="text" name="num1" placeholder="Number 1">
<input type="text" name="num2" placeholder="Number 2">
<br>
<button type="submit" name="submit" value="submit">Generate</button>
</form>
<p>Response:</p>
<?php
if (isset($_GET["submit"])) {
$name = $_GET['num1'] . ' ' . $_GET['num2'];
echo $name;
}
?>
</body>
</html>
It seems like the info is getting passed to the URL when I click the button because this is what it shows when entering "aaaa" and "bbbb":
file:///storage/emulated/0/web-files/index.php?num1=aaaa&num2=bbbb&submit=submit
content won't change as php produces static content when executed as a part of html.
– Dr. Kevin Wang Jan 07 '19 at 05:43