0% found this document useful (0 votes)
2 views

lampPartA5

Uploaded by

mynameyourname58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

lampPartA5

Uploaded by

mynameyourname58
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Question 5

Pdf:

PGM-5-6

Write a Php program to demonstrate $_POST method and display


pattern.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Program Five</title>
</head>
<body>
<?php
$noOfLines = "";
$symbol = "";
if (isset($_POST["submit"])) {
$noOfLines = $_POST["line"];
$symbol = $_POST["symbol"];
}
?>
<h2>Pyramid</h2>
<form method="post">
Enter the loop number:
<input type="number" name="line" required value="<?php echo $noOfLines; ?>"><br><br>

Enter the symbol:


<input type="text" name="symbol" required value="<?php echo $symbol; ?>"><br><br>

<input type="submit" value="Submit" name="submit">


<input type="reset" value="Clear" name="clr"><br><br> /* this button is optional */
</form>

Question 5 1
<?php
if ($noOfLines and $symbol) {
for ($i = 0; $i < $noOfLines; $i++) {

for ($j = 0; $j < $i + 1; $j++) {


echo "<b>$symbol</b>&nbsp;&nbsp;";
}

echo "<br>";
}
}
?>
</body>
</html>

OR

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Program Five</title>
<?php
$noOfLines = "";
$symbol = "";
if (isset($_POST["submit"])) {
$noOfLines = $_POST["line"];
$symbol = $_POST["symbol"];
}
?>
</head>
<body>
<h2>Pyramid</h2>
<form method="post">
Enter the loop number:
<input type="number" name="line" required value="<?php echo $noOfLines; ?>"><br><br>

Enter the symbol:


<input type="text" name="symbol" required value="<?php echo $symbol; ?>"><br><br>

<input type="submit" value="Submit" name="submit">


<input type="reset" value="Clear" name="clr"><br><br> /* this button is optional */
</form>

<?php
function patternFun($noOfLines, $symbol) {
for ($i = 0; $i < $noOfLines; $i++) {

Question 5 2
for ($j = 0; $j < $i + 1; $j++) {
echo "<b>$symbol</b>&nbsp;&nbsp;";
}

echo "<br>";
}
}

if ($noOfLines and $symbol) {


patternFun($noOfLines, $symbol);
}
?>
</body>
</html>

Output:

Question 5 3

You might also like