Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PHP
- Lab-5
- 1.
- .html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Registration Form</title>
- </head>
- <body>
- <center>
- <h1>Register For a Technical and Cultural Fair of Dharmsihn Desai University</h1>
- <form action="Q-1.php" method="post">
- <table>
- <tr>
- <td>Name: </td>
- <td><input type="text" name="name"></td>
- </tr>
- <tr>
- <td>Branch: </td>
- <td><input type="text" name="branch" id="branch"></td>
- </tr>
- <tr>
- <td>Semester:</td>
- <td><input type="number" name="sem" id="sem" min="1" max="8"></td>
- </tr>
- <tr>
- <td>Roll Number:</td>
- <td><input type="text" name="rno" id="rno"></td>
- </tr>
- <tr>
- <td>Email Id:</td>
- <td><input type="email" name="email" id="email"></td>
- </tr>
- <tr>
- <td>Contact Number:</td>
- <td><input type="number" name="mno" id="mno"></td>
- </tr>
- <tr>
- <td>Subject of Interest:</td>
- <td>
- <select name="int" id="int">
- <option value="1">Cultural</option>
- <option value="2">Web Publishing</option>
- <option value="3">Technical</option>
- <option value="4">Finance</option>
- <option value="5">Publication</option>
- <option value="6">Reception</option>
- <option value="7">Hosting</option>
- </select>
- </td>
- </tr>
- <tr>
- <td>Signature</td>
- <td><input type="file" name="sign" id="sign"></td>
- </tr>
- <tr>
- <td>Past Experience</td>
- <td>Yes<input type="radio" name="past" id="past">No<input type="radio" name="past" id="past"></td>
- </tr>
- <tr>
- <td><input type="submit" value="Submit" name="Submit"></td>
- </tr>
- </table>
- </form>
- </center>
- </body>
- </html>
- .php
- <?php
- echo "<pre>";
- print_r($_POST);
- echo "</pre>";
- ?>
- 2.
- .html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Form</title>
- </head>
- <body>
- <form action="Q-2.php" method="post">
- Enter No1: <input type="number" name="no1" id="no1"><br>
- Enter No2: <input type="number" name="no2" id="no2"><br>
- <input type="submit" value="Add" name="add">
- <input type="submit" value="Diff" name="diff">
- <input type="submit" value="Mul" name="mul">
- <input type="submit" value="Div" name="div">
- </form>
- </body>
- </html>
- .php
- <?php
- if(isset($_POST))
- {
- $no1 = $_POST['no1'];
- $no2 = $_POST['no2'];
- if(isset($_POST['add']))
- {
- echo "Addition: " . $no1 + $no2;
- }
- elseif(isset($_POST['diff']))
- {
- echo "Difference: " . $no1 - $no2;
- }
- elseif(isset($_POST['mul']))
- {
- echo "Multiplication: " . $no1 * $no2;
- }
- elseif(isset($_POST['div']))
- {
- echo "Division: " . $no1 / $no2;
- }
- }
- ?>
- 3.
- .html
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Form</title>
- </head>
- <body>
- <form action="Q-3.php" method="post">
- Enter 10 numbers (Comma Separated): <input type="text" name="nums"><br>
- <input type="submit" value="submit" name="submit">
- </form>
- </body>
- </html>
- .php
- <?php
- if(isset($_POST))
- {
- $str = $_POST['nums'];
- $arr = explode(',',$str);
- $sum = 0;
- foreach ($arr as $v) {
- $sum += $v;
- }
- echo "Sum: " . $sum;
- }
- ?>
- 4.
- sign.php
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Sign in</title>
- </head>
- <body>
- <form action="#" method="post">
- Username: <input type="text" name="uname" id="uname"><br>
- Age: <input type="text" name="age" id="age"><br>
- City: <input type="text" name="city" id="city"><br>
- <input type="submit" value="Submit" name="submit">
- </form>
- </body>
- </html>
- <?php
- if(isset($_COOKIE['uname']))
- {
- header("Location:view.php");
- exit();
- }
- if(isset($_POST))
- {
- if(isset($_POST['submit']))
- {
- $uname = $_POST['uname'];
- $age = $_POST['age'];
- $city = $_POST['city'];
- setcookie("uname",$uname);
- setcookie("age",$age);
- setcookie("city",$city);
- header("location: view.php");
- exit();
- }
- }
- ?>
- view.php
- <?php
- echo "<pre>";
- print_r($_COOKIE);
- echo "</pre>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement