1 Vastaus
2
05/11/2024 8:27 am
- In case the form was submitted and the input parameter num exists, take its value as integer using the function intval(string).
- Then, just print the results: echo $n * 2.
The code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>First Steps Into PHP</title>
</head>
<body>
<form>
N: <input type="text" name="num"/>
<input type="submit"/>
</form>
<?php
if (isset($_GET['num'])) {
$n = intval($_GET['num']);
echo $n * 2;
}
?>
</body>
</html>

