11. Write a program in PHP to add three numbers. <!doctype html> <html> <head> <title>Year : 2015 | Q : 11</title> </head> <body> <?php $sum = 0; if(isset($_POST[‘add’])) $sum = $_POST[‘n1’]+$_POST[‘n2’]+$_POST[‘n3’]; ?> <form method = ‘post’> Number 1: <input type = ‘number’ name = ‘n1’ value = ‘0’><br> Number 2: <input type = ‘number’ name […]
Web Programming II – Solutions – 2016
11. Write a PHP program to create a web form that contains a textbox for names, and checkboxes for hobbies. When a form is submitted, check a name is entered, and at least one of the hobbies is selected. <!doctype html> <html> <head> <title>Year : 2016 | Q : 11</title> </head> <body> <form method = […]
Web Programming II – Solutions -2017
11. Write a PHP code to perform server-side validation. (Check for empty, alphabets, numbers, email and password length validation) <!doctype html> <html> <head> <title>Year : 2017 | Q : 11</title> </head> <body> <?php function validate($n,$a,$e,$p) { //Checking for empty spaces if($n==”||$a==”||$e==”||$p==”){ echo ‘Empty spaces not permitted’; return false; } //Checking for numbers $regN = “/^[A-Z]+[A-z\s]+[a-z]$/m”; […]
Web Programming II – TU Solution – 2018
11. Write a PHP program to create a form that contains two textboxes that accept numbers and a submit button. When submit button is clicked, the sum of two numbers will be displayed. <!doctype html> <html> <head> <title>Year : 2018 | Q : 11</title> </head> <body> <?php if(isset($_POST[‘add’])) { $n1 = $_POST[‘n1’]; $n2 = $_POST[‘n2’]; […]

