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

Php Journal

The document provides a comprehensive guide on various PHP programming tasks, including arithmetic operations, date and time formatting, checking odd/even numbers, defining constants, and creating arrays. It also covers user input handling through forms, database interactions for a marksheet, and a simple login validation system. Each section includes PHP code snippets and their expected outputs, demonstrating practical applications of PHP in web development.

Uploaded by

jaydip3174
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)
1 views

Php Journal

The document provides a comprehensive guide on various PHP programming tasks, including arithmetic operations, date and time formatting, checking odd/even numbers, defining constants, and creating arrays. It also covers user input handling through forms, database interactions for a marksheet, and a simple login validation system. Each section includes PHP code snippets and their expected outputs, demonstrating practical applications of PHP in web development.

Uploaded by

jaydip3174
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/ 47

PHP JOURNAL

1. Perform arithmetic operations on 2 predefined number values.


<?php
$a=10;
$b= 2;

echo"Addition: ".($a+$b);
echo "<br>";

echo"Subtraction: ".($a-$b);
echo "<br>";

echo"Division: ".($a/$b);
echo "<br>";

echo"Multiplication: ".($a*$b);
echo "<br>";
?>

OUTPUT:
Addition: 12
Subtraction: 8
Division: 5
Multiplication: 20
2. Print current date and time using date() function.

સર એે લખાયેલાે

<?php
// Display the current date and time in the format: day-month-year hour:minute:second
echo date("d-m-Y h:i:s");
?>
Note: we have to use i for minutes, not m

OUTPUT:
06-02-2025 09:18:55

OR India's current time-based

<?php
// Set the timezone to Indian Standard Time (IST)
date_default_timezone_set("Asia/Kolkata");

// Display the current date and time in the format: day-month-year hour:minute:second
echo date("d-m-Y h:i:s");
?>

OUTPUT:
06-02-2025 01:48:55
3. Display dates in different formats.

<?php
echo date('Y') . '<br>'; // Output: 2025

echo date('F-Y') . '<br>'; // Output: February-2025

echo date('d-F-Y') . '<br>'; // Output: 06-February-2025

echo date('l-d-F-Y') . '<br>'; // Output: Tuesday-06-February-2025


?>

OUTPUT:
2025
February-2025
06-February-2025
Thursday-06-February-2025
4. Check whether a given number is odd or even.

<?php
$a = 8;

if ($a % 2 == 0)
{
echo "Number is even";
} else
{
echo "Number is odd";
}
?>

OUTPUT:
Number is even
5. Print constant value (i.e., $pi=3.14) of the variable OR Use define to find the area of a
circle, where Area=pi*r*r.

<?php
define("PI", 3.14);
$r = 2;
$area = PI * $r * $r;
echo "The area of the circle is: " . $area;
?>

OUTPUT:
The area of the circle is: 12.56
6.Find the maximum number among three numbers (using if..else statement).
<?php
$a = 10;
$b = 25;
$c = 15;

if ($a >= $b && $a >= $c)


{
echo "a is the greatest number.";
} elseif ($b >= $a && $b >= $c)
{
echo "b is the greatest number.";
} else
{
echo "c is the greatest number.";
}
?>

OUTPUT:
b is the greatest number.
7. Perform an arithmetic operation based on user choice (using Switch case and passing
the parameter between two pages).

J7.html

<html>
<head>
<title>Simple Calculation</title>
</head>
<body>
<h1>Simple Calculation</h1>
<form action="J7.php" method="post">
NO1: <input type="text" id="no1" name="no1" value=""><br>
NO2: <input type="text" id="no2" name="no2"value=""><br>
Operation:<select name="op" id="op">
<option value="+">Addition</option>
<option value="-">Subtraction </option>
<option value="*">Multiplication</option>
<option value="/">Division </option>
</select><br><br>

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


<input type="reset" name="clear" value="Clear">
</form>
</body>
</html>
J7.php
<?php
if (isset($_POST['submit'])) {
$a = $_POST['no1'];
$b = $_POST['no2'];
$ch = $_POST['op'];

switch ($ch) {
case '+':
echo "Addition of two numbers: " . ($a + $b);
break;
case '-':
echo "Subtraction of two numbers: " . ($a - $b);
break;
case '*':
echo "Multiplication of two numbers: " . ($a * $b);
break;
case '/':
echo "Division of two numbers: " . ($a / $b);
break;
default:
echo "Invalid Choice";
break;
}
}
?>
OUTPUT:

Addition of two numbers: 12


8. Use $_POST[] or $_GET[] or isSet() and create:
i. Fibonacci series for n number.
ii. Design a simple calculator.
iii. Find the sum of factorial using $_SERVER['PHP_SELF'].

i. Fibonacci series for n number.

<html>
<head>
<title>Fibonacci </title>
</head>
<body><h2>Fibonacci series</h2>
<form action="" method="post">
Number: <input type="text" name="number" value="<?php echo $_POST['number'] ?? '';
?>">
<input type="submit" name="print" value="Print Fibonacci series">
</form>

<?php
function fibo($number) {
if ($number == 0) {
return 0;
} else if ($number == 1) {
return 1;
} else {
return fibo($number - 1) + fibo($number - 2);
}
}
if (isset($_POST['print'])) {
$number = $_POST['number'];
for ($cnt = 0; $cnt < $number; $cnt++) {
echo "Fibonacci($cnt): " . fibo($cnt) . "<br>";
}
}
?>

</body>
</html>
OUTPUT

ii. Design a simple calculator.

<html>
<head>
<title>Simple Calculator</title>
</head>
<body>

<h2>Simple Calculator</h2>
<form action="" method="post">
NO1: <input type="text" name="no1" value=""><br>
NO2: <input type="text" name="no2" value=""><br>
Operation:
<select name="op">
<option value="+">Addition</option>
<option value="-">Subtraction</option>
<option value="*">Multiplication</option>
<option value="/">Division</option>
</select><br><br>
<input type="submit" name="calculate" value="Calculate">
</form>
<?php
if (isset($_POST['calculate'])) {
$no1 = $_POST['no1'];
$no2 = $_POST['no2'];
$op = $_POST['op'];

if (is_numeric($no1) && is_numeric($no2)) {


$result = 0;
if ($op == '+') {
$result = $no1 + $no2;
} else if ($op == '-')
{
$result = $no1 - $no2;
} else if ($op == '*')
{
$result = $no1 * $no2;
} else if ($op == '/')
{
$result = $no1 / $no2; // Removed the condition for dividing by zero
} else {
$result = "Invalid Operation";
}
echo "<p>Result: $result</p>";
}
}
?>
</body>
</html>

OUTPUT

Result: 5

iii. Find the sum of factorial using $_SERVER['PHP_SELF'].

<html>
<head>
<title>Factorial</title>
</head>
<body><h2>Factorial</h2>
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>"
method="post">
Enter Number : <input type="number" name="number" id="number">
<input type="submit" name="submit" value="submit">
</form>
<?php
if ($_POST) {
$fact = 1;
$number = $_POST['number'];
echo "Factorial of $number :</br></br>";

for ($i = 1; $i <= $number; $i++) {


$fact = $fact * $i;
}

echo $fact . "</br>";


}
?>
</body>
</html>

OUTPUT
9. Create an array of type (Numeric, Associative, and Multidimensional) and display
content on the screen.
<?php
// Numeric Array
$numericArray = array(10, 20, 30);

// Display Numeric Array


echo "Numeric Array:<br>";
foreach ($numericArray as $value) {
echo $value . "<br>";
}

// Associative Array
$associativeArray = array(
"name" => "RAM BHAI",
"age" => 25,
"city" => "HOME"
);

// Display Associative Array


echo "<br>Associative Array:<br>";
foreach ($associativeArray as $key => $value) {
echo "$key: $value<br>";
}

// Multidimensional Array
$multiArray = array(
array(1, 2, 3),
array(4, 5, 6),
array(7, 8, 9)
);

// Display Multidimensional Array


echo "<br>Multidimensional Array:<br>";
foreach ($multiArray as $row) {
foreach ($row as $value) {
echo $value . " ";
}
echo "<br>";
}
?>
OUTPUT:
Numeric Array:
10
20
30

Associative Array:
name: RAM BHAI
age: 25
city: HOME

Multidimensional Array:
123
456
789
10. Create an array with 10 elements, find the maximum and minimum elements from it.
<?php
function getMax($array)
{$n = count($array);
$max = $array[0];

for ($i = 1; $i < $n; $i++)


{
if ($array[$i] > $max)
{
$max = $array[$i];
}
}
return $max;
}
function getMin($array)
{
$n = count($array);
$min = $array[0];

for ($i = 1; $i < $n; $i++)


{
if ($array[$i] < $min)
{
$min = $array[$i];
}
}
return $min;
}
$array = array(1, 2, 3, 4, 5, 6, 23, 78, 24, 79);

echo "Maximum number is : " . getMax($array) . "<br>";


echo "Minimum number is: " . getMin($array) . "<br>";
?>

OUTPUT:
Maximum number is: 79
Minimum number is: 1

11. Find the occurrence of a character within a given string.

<?php
$ch="a";
$str = "Sardar Patel University";
$occ = substr_count($str, $ch);

echo "The number of occurrences is/are:$occ";


?>

OUTPUT:
The number of occurrences is/are:3
12. Write a program to generate the even number & odd number series up to a given
number.
<html>
<head
<title>Odd Even</title>
</head>
<body>
<form method="POST">
Enter a Number:<input type="text" name="number" ><br>
<input type="submit" value="Submit">
</form>

<?php
$a="";
$b="";
if ($_POST)
{
$n = $_POST['number'];

for ($i = 1; $i <= $n; $i++) {


if ($i % 2 == 0)
{
$a=$a.",".$i;
}
else
{
$b=$b.",".$i;
}
}
echo "Even Number is".$a."</br>";
echo "odd Number is".$b;
}
?>
</body>
</html>

OUTPUT:

Even Number is,2,4,6,8,10


odd Number is,1,3,5,7,9
13. Create a mark sheet of 3 subjects' marks for sem-2. Calculate total, percentage, insert
data into the database, and display all the records.
where
Database name: marksheet
Table name: marks
Field Name Type(Size)
roll_no Int(3)
name Varchar(10)
m1 Int(3)
m2 Int(3)
m3 Int(3)
Total Int(3)
per Double(5,2)

J13.html

<html>
<head>
<title>Marksheet SEM-6</title>
</head>
<body>
<form action="J13.php" method="post">
ROLL NO :<input type="text" name="rno"/><br>
NAME :<input type="text" name="nm"/><br>
MARKS OF SUB 1:<input type="text" name="m1"/><br>
MARKS OF SUB 2:<input type="text" name="m2"/><br>
MARKS OF SUB 3:<input type="text" name="m3"/><br>
<input type="submit" >
</body>
</html>
J13.php
<?php
$con = mysqli_connect("localhost", "root", "", "marksheet");
if ($con)
{
$rno = $_POST["rno"];
$nm = $_POST["nm"];
$m1 = $_POST["m1"];
$m2 = $_POST["m2"];
$m3 = $_POST["m3"];
$tot = $m1 + $m2 + $m3;
$per = $tot / 3;

$ins = "INSERT INTO marks VALUES('$rno','$nm','$m1','$m2','$m3','$tot','$per')";


if (mysqli_query($con, $ins)) // Corrected function usage
{
echo "record inserted successfully<br>";
$sel = "SELECT * FROM marks";
$result = mysqli_query($con, $sel); // Corrected function order
echo "<table border='1'>";
echo "<tr>";
echo "<th>RollNO</th>";
echo "<th>Name</th>";
echo "<th>M1</th>";
echo "<th>M2</th>";
echo "<th>M3</th>";
echo "<th>Total</th>";
echo "<th>Percentage</th>";
echo "</tr>";
while ($row = mysqli_fetch_row($result))
{
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "<td>".$row[4]."</td>";
echo "<td>".$row[5]."</td>";
echo "<td>".$row[6]."</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
echo "Error: Could not execute $ins. " . mysqli_error($con); // Passed connection to
function
}
}
else
{
echo "Error..DB not connected. " . mysqli_connect_error(); // Used correct error function
}
mysqli_close($con);
?>
14. Design a login form and validate to username= “ADMIN” and password= “birthdate”.
Display appropriate message on submitting form,

J14.html

<html>
<head>
<title>Login</title>
</head>
<body>
<form action="J14.php" method="post">
USERNAME: <input type="text" name="unm" value=""><br>
PASSWORD: <input type="text" name="pwd" value=""><br>
<input type="submit" name="submit" value="Login">
</form>
</body>
</html>

J14.php

<?php
session_start();

$conn = new mysqli("localhost", "root", "", "marksheet");

if (isset($_POST['submit'])) {
$name = $_POST['unm'];
$pwd = $_POST['pwd'];
if($name!="&&$pwd=")
{
$sel = "SELECT * FROM login WHERE unm = '$name' AND pwd = '$pwd'";
$query=mysqli_query($conn,$sel)or die(mysqli_error($conn));
$res=mysqli_fetch_row($query);

if($res)
{
$_SESSION['name'] = $name;
//header(location:welcome.php);
echo" Welcome to home";
}
else
{
echo "You Entered username or password is incorrect";
}

}
else
{
echo "Enter both usernmae and password";
}
}
?>
OUTPUT:

Welcome to home
15.

J15.php
<html>
<head>
<title>Journal-15</title>
</head>
<body>
<form action="Insert.php" method="post">
First name: <input type="text" name="fname" value=""><br>
Last name: <input type="text" name="lname" value=""><br>
Date of Birth: <input type="date" name="bdate" value=""><br>
//you can use text or date in DOB
<input type="submit" name="submit" value="Submit"><br>
<a href="Insert.php">Insert</a><br>
<a href="Display.php">Display</a>
</form>
</body>
</html>
Display.php
<!-- Display.php -->
<?php
$con = mysqli_connect("localhost", "root", "", "birthday");

if (!$con) {
die("Error.. Not Connected: " . mysqli_connect_error());
} else {
$query = "SELECT * FROM bdate"; // Fixed table name
$result = mysqli_query($con, $query);

if (mysqli_num_rows($result) > 0) {
echo "<table>";
echo "<tr>";
echo "<th>First Name</th>";
echo "<th>Last Name</th>";
echo "<th>Date of Birth</th>";
echo "<th>Edit</th>";
echo "<th>Delete</th>";
echo "</tr>";

while ($row = mysqli_fetch_assoc($result)) {


$id = $row['ID']; // Corrected capitalization
$fnm = $row['fname'];
$lnm = $row['Lname'];
$dob = $row['Bdate'];
echo "<tr>";
echo "<td>$fnm</td>";
echo "<td>$lnm</td>";
echo "<td>$dob</td>";
echo "<td><a href='edit.php?GETID=$id'>Edit</a></td>";
echo "<td><a href='delete.php?del=$id'>Delete</a></td>";
echo "</tr>";
}
echo "</table>";
} else {
echo "<p>No records found.</p>";
}
mysqli_close($con);
}
?>

Delete.php
<!-- delete.php -->
<?php
$con = mysqli_connect("localhost", "root", "", "birthday");

if (isset($_GET['del']))
{
$id = $_GET['del'];

$query = "DELETE FROM bdate WHERE id='$id'";


$result = mysqli_query($con, $query);

if ($result)
{
header("Location: display.php");
} else
{
echo "Please check your query";
}
} else
{
header("Location: display.php");
exit();
}

mysqli_close($con);
?>

Insert.php
<!-- insert.php -->
<?php
$con = mysqli_connect("localhost", "root", "", "birthday");

if (!$con)
{
die("Error.. Not Connected: " . mysqli_connect_error());
}

if (isset($_POST['submit']))
{
if (empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['bdate']))
{
echo "Please fill in the blanks";
}
else
{
$fnm = $_POST['fname'];
$lnm = $_POST['lname'];
$dob = $_POST['bdate'];

$query = "INSERT INTO bdate (fname, lname, bdate) VALUES ('$fnm', '$lnm', '$dob')";
$result = mysqli_query($con, $query);

if ($result)
{
header("Location: display.php");
exit();
}
else
{
echo "Please check your query";
}
}
}
else
{
header("Location: j15.php");
exit();
}

mysqli_close($con);
?>
Edit.php
<!-- edit.php -->
<?php
$con = mysqli_connect("localhost", "root", "", "birthday");

if (!$con)
{
die("Error.. Not Connected: " . mysqli_connect_error());
}

$id = $_GET['GETID'];

$query = "SELECT * FROM bdate WHERE id='$id'";


$result = mysqli_query($con, $query);

while ($row = mysqli_fetch_assoc($result))


{
$id = $row['ID'];
$fnm = $row['fname'];
$lnm = $row['Lname'];
$dob = $row['Bdate'];
}

mysqli_close($con);
?>
<!DOCTYPE html>
<html>
<head>
<title>Edit Record</title>
</head>
<body>
<form action="update.php" method="post">
<input type="hidden" name="id" value="<?php echo $id; ?>">
First name: <input type="text" name="fname" value="<?php echo $fnm; ?>"><br>
Last name: <input type="text" name="lname" value="<?php echo $lnm; ?>"><br>
Date of Birth: <input type="date" name="bdate" value="<?php echo $dob; ?>"><br>
<input type="submit" name="update" value="Update">
</form>
</body>
</html>

Update.php
<?php
$con = mysqli_connect("localhost", "root", "", "birthday");

if (!$con) {
die("Error.. Not Connected: " . mysqli_connect_error());
}

if (isset($_POST['update'])) { // Ensure form uses 'update' instead of 'submit'


if (empty($_POST['fname']) || empty($_POST['lname']) || empty($_POST['bdate'])) {
echo "Please fill in the blanks";
} else {
$id = $_POST['id']; // Get ID from hidden input in edit.php
$fnm = $_POST['fname'];
$lnm = $_POST['lname'];
$dob = $_POST['bdate'];

// Correct UPDATE query


$query = "UPDATE bdate SET fname='$fnm', lname='$lnm', bdate='$dob' WHERE
id='$id'";
$result = mysqli_query($con, $query);

if ($result) {
header("Location: display.php");
exit();
} else {
echo "Error updating record.";
}
}
} else {
header("Location: j15.php");
exit();
}

mysqli_close($con);
?>

OUTPUT:
16. Delete multiple records from the database on given ID.
<html>
<head>
<title>Student Information</title>
</head>

<body>
<form method="POST">
<table border="1">
<tr>
<td>Roll Number:</td>
<td><input type="text" name="id"/></td>
</tr>
<tr>
<td>Name:</td>
<td><input type="text" name="nm"/></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Delete" name="Submit"/>
</td>
</tr>
</table>
</form>
<?php
$cn = mysqli_connect('localhost', 'root', '', 'birthday');
if ($cn)
{
if (isset($_POST['Submit']))
{
$id = $_POST['id'];
$nm = $_POST['nm'];
$del = "DELETE FROM stud_info WHERE id='$id'";
mysqli_query($cn, $del);
}
echo '<table border="1">';
echo '<tr>';
echo '<th>Roll no</th>';
echo '<th>Name</th>';
echo '</tr>';
$dis = "SELECT * FROM stud_info";
$result = mysqli_query($cn, $dis);
while ($row = mysqli_fetch_assoc($result))
{
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['nm'] . '</td>';
echo '</tr>';
}
echo '</table>';
mysqli_close($cn);
}
Else
{
echo "DB not Connected";
}
?>
</body>
</html>

OUTPUT:
17. Search records from the database using where username starts with 'A'.
<?php
$cn = mysqli_connect('localhost', 'root', '', 'birthday');
if ($cn) {
echo "DB is connected...";
echo '<table border="1">';
echo '<tr>';
echo '<th>Roll Number</th>';
echo '<th>Name</th>';
echo '</tr>';
$query1 = "SELECT * FROM stud_info WHERE nm LIKE 'A%'";
$result = mysqli_query($cn, $query1);

if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['nm'] . '</td>';
echo '</tr>';
}
} else
{
echo "0 results";
}

echo '</table>';
}
mysqli_close($cn);
?>
18. Check the existence of file or database using die() function to handle an error and risk
of crashing.
// for file
<?php
if (file_exists("mytestfile.txt"))
{
$file = fopen("mytestfile.txt", "r");
} else
{
die("Error: The file does not exist");
}
?>

//for database
<?php
$con = mysqli_connect('localhost', 'root', '', 'TYIT');

if (!$con)
{
die('Could not connect: ' . mysqli_connect_error());
}

$sql = "SELECT * FROM student WHERE class = 'TYIT'";


$result = mysqli_query($con, $sql);

if (mysqli_num_rows($result) > 0)
{
while ($row = mysqli_fetch_assoc($result)) {
print_r($row);
}
}
else
{
echo "No records found!";
}

mysqli_close($con);
?>
19. Write a script which store the password of the user using cookies and retrieve it using
table.
<html>
<head>
<script>
function check()
{
if(document.getElementById("user").value=="<?php echo isset($_COOKIE['user']) ?
$_COOKIE['user'] : ''; ?>")
{
document.getElementById("pass").value="<?php echo isset($_COOKIE['pass']) ?
$_COOKIE['pass'] : ''; ?>";
}
}
</script>
</head>
<body>
<form method="post">
Username: <input type="text" id="user" name="user">
<br>
Password: <input type="password" id="pass" name="pass" onfocus="check()">
<br>
<input type="checkbox" name="remember"> Remember me
<br>
<input type="submit" name="save" value="Save">
</form>
</body>
</html>

<?php
if(isset($_POST['save']))
{
$user = $_POST['user'];
$pass = $_POST['pass'];

if(isset($_POST['remember']))
{
setcookie("user", $user, time() + 300);
setcookie("pass", $pass, time() + 300);
}
}
?>
20. Count the number of page hit using session variable.
<?php
session_start();
if (isset($_SESSION['visit'])) {
$_SESSION['visit'] += 1;
echo("page visited " . $_SESSION['visit'] . " timer");
} else {
$_SESSION['visit'] = 1;
echo("you visit site for " . $_SESSION['visit'] . " timer");
}
?>
<html>
<body bgcolor="pink">
<br>
site visited earlier:
<?php
echo($_SESSION['visit']);
?>
</body>
</html>
21. Write a function to validate email (using Regular Expression).

<!DOCTYPE html>
<html>
<head>
<style>
.error { color: #FF0000; }
</style>
</head>
<body>

<?php
// Define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"])) {
$nameErr = "Name is required";
} else {
$name = test_input($_POST["name"]);
}

if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = test_input($_POST["email"]);
}

if (empty($_POST["website"])) {
$website = "";
} else {
$website = test_input($_POST["website"]);
}

if (empty($_POST["comment"])) {
$comment = "";
} else {
$comment = test_input($_POST["comment"]);
}

if (empty($_POST["gender"])) {
$genderErr = "Gender is required";
} else {
$gender = test_input($_POST["gender"]);
}
}

function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>

<h2>PHP Form Validation Example</h2>


<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
Name: <input type="text" name="name">
<span class="error">* <?php echo $nameErr; ?></span>
<br><br>
Email: <input type="text" name="email">
<span class="error">* <?php echo $emailErr; ?></span>
<br><br>
Website: <input type="text" name="website">
<span class="error"><?php echo $websiteErr; ?></span>
<br><br>
Comment: <textarea name="comment" rows="5" cols="40"></textarea>
<br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="other">Other
<span class="error">* <?php echo $genderErr; ?></span>
<br><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

You might also like