Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Activity 4 sign up page-->
- <!DOCTYPE html>
- <html>
- <head>
- <title>Sign in form</title>
- <style>
- body{
- background-color:#2A2D5C;
- }
- .first{
- background-color:#24264c;
- height:500px;
- width:550px;
- margin: 70px 400px 400px 480px;
- }
- h1{
- background-color:#080B40;
- color:snow;
- text-align:center;
- font-family:helvetica;
- padding-bottom:10px;
- padding-top:10px;
- }
- .second{
- background-color:#080B40;
- height:70px;
- width:100%;
- margin-top:50px;
- }
- #b{
- height:35px;
- width:470px;
- margin:5px 40px 0px 40px;
- background-color:rgb(36,38,50);
- padding: 2px 2px 6px 8px ;
- border: 1px solid rgb(36,38,50);
- border-radius:4px;
- }
- #a{
- height:35px;
- margin:25px 40px 0px 40px;
- width:470px;
- background-color:rgb(36,38,50);
- padding: 2px 2px 6px 8px ;
- border: 1px solid rgb(36,38,50);
- border-radius:4px;
- }
- input[placeholder]{
- font-size:15px;
- }
- #c {
- background-color: #4CAF50;
- border: none;
- color: snow;
- padding: 5px 32px;
- text-decoration: none;
- margin: 4px 2px;
- cursor: pointer;
- height:45px;
- margin:25px 40px 0px 40px;
- width:480px;
- border-radius:4px;
- border-bottom:4px solid #276E28;
- }
- input[value]{
- font-size:25px;
- font-weight:bold;
- }
- #d{
- font-size:15px;
- color:snow;
- margin-top:25px;
- margin-left:40px;
- }
- span{
- color:snow;
- font-size:15px;
- font-family:verdana;
- }
- a{
- text-decoration:none;
- color:snow;
- margin-left:200px;
- font-size:15px;
- font-family:verdana;
- }
- .face{
- height:40px;
- margin:50px 40px 0px 40px;
- width:200px;
- background-color:rgb(47,51,147);
- border-top:2px solid rgb(47,51,147);
- border-bottom:2px solid rgb(47,91,147);
- border-radius:4px;
- }
- img{
- height:35px;
- width:30px;
- }
- #f{
- margin-left:3px;
- margin-bottom:8px;
- color:snow;
- font-size:15px;
- font-family:verdana;
- }
- .twi{
- float:right;
- height:40px;
- margin:-43px 40px 0px 250px;
- width:200px;
- background-color:rgb(66,177,238);
- border-top:2px solid rgb(47,51,147);
- border-bottom:2px solid rgb(47,91,147);
- border-radius:4px;
- }
- #abc{
- margin:3px 0px -5px 10px;
- }
- #t{
- margin-bottom:300px;
- }
- #n{
- margin-left:30px;
- text-decoration:none;
- color:snow;
- font-size:15px;
- font-family:verdana;
- }
- #si{
- background-color: #3d9e70;
- border:none;
- color: snow;
- padding: 5px 20px;
- text-decoration: none;
- margin: 4px 2px;
- cursor: pointer;
- height:45px;
- margin:13px 10px 0px 210px;
- width:130px;
- border-radius:4px;
- border-bottom:4px solid #276E28;
- }
- .face:hover{
- cursor: pointer;}
- .twi:hover{cursor: pointer;}
- </style>
- </head>
- <body>
- <div class="first">
- <h1>Sign In</h1>
- <input id="b" type="text" name="uname" placeholder="User Name or Email"><br>
- <input id="a" type="text" name="pass" placeholder="User Password"><br>
- <input id="c" type="button" value="LOGIN"><br>
- <input id="d" type="checkbox" name="rm" value="rm"> <span>Remember me</span>
- <a href="#">Forgot Password?</a>
- <div class="face">
- <img src="C:\Users\Piyushjaiswal\Desktop\facebook_icon.png" alt="facebook"><span id="f">Login with Facebook</span>
- </div>
- <div class="twi">
- <img id="abc" src="C:\Users\Piyushjaiswal\Desktop\twitter_318-136405.jpg" alt="twitter"><span id="t">Login with Twitter</span>
- </div>
- <div class="second">
- <a id="n" href="#">Need new account?</a>
- <input id="si" type="button" value="Sign Up">
- </div>
- </div>
- </body>
- </html>
- --------------------------------------------------------------------
- <!-- Activity 5 column one-->
- <!DOCTYPE html>
- <html>
- <head>
- <style type="text/css">
- @keyframes example {
- 0% {background-color: red;}
- 25% {background-color: yellow;}
- 50% {background-color: blue;}
- 100% {background-color: green;}
- }
- h1{
- padding: 25px;
- text-align: center;
- padding: 50px;
- }
- ul {
- list-style-type: none;
- margin: 0;
- padding: 0;
- overflow: hidden;
- background-color: #333333;
- text-align: center;
- }
- li {
- float: left;
- }
- li a {
- display: block;
- color: white;
- text-align: center;
- text-decoration: none;
- padding: 20px;
- }
- li a:hover {
- background-color: GreenYellow;
- }
- .fullpage{
- background-image: url('left.jpg');
- border:2px solid black;
- border-radius: 5px;
- outline: 2px solid red;
- outline-offset: 5px; }
- .para1 {
- column-count: 3;
- column-gap: 40px;
- column-rule-style: solid;
- font-family: palatino;
- font-size:20px;
- position: relative;
- }
- .para2 {
- column-count: 2;
- column-gap: 40px;
- column-rule-style: solid;
- font-family: palatino;
- font-size:20px;
- }
- .header{
- animation-name: example;
- animation-duration: 4s;
- animation-iteration-count: infinite;
- animation-timing-function: ease-in;
- }
- </style>
- </head>
- <body>
- <div class="fullpage">
- <div class="header">
- <h1>Happy Independence day India</h1>
- </div>
- <hr>
- <div class="below header">
- <ul>
- <li><a href="#home">Home</a></li>
- <li><a href="#news">News</a></li>
- <li><a href="#contact">Contact</a></li>
- <li><a href="#about">About</a></li>
- </ul>
- </div>
- <hr>
- <div class="para1">
- <h2>
- The Great Country India
- </h2><hr>
- The Indian subcontinent was home to the urban Indus Valley Civilisation of the 3rd millennium BCE. In the following millennium, the oldest scriptures associated with Hinduism began to be composed. Social stratification, based on caste, emerged in the first millennium BCE, and Buddhism and Jainism arose. Early political consolidations took place under the Maurya and Gupta empires; the later peninsular Middle Kingdoms influenced cultures as far as southeast Asia. In the medieval era, Judaism, Zoroastrianism, Christianity, and Islam arrived, and Sikhism emerged, all adding to the region's diverse culture. Much of the north fell to the Delhi sultanate; the south was united under the Vijayanagara Empire. The economy expanded in the 17th century in the Mughal Empire. In the mid-18th century, the subcontinent came under British East India Company rule, and in the mid-19th under British crown rule. A nationalist movement emerged in the late 19th century, which later, under Mahatma Gandhi, was noted for nonviolent resistance and led to India's independence in 1947.
- </div>
- <hr>
- <h2 align="center">
- About Indian Independence day
- </h2>
- <hr>
- <div class="para2">
- Independence Day is annually observed on 15th August, as a national holiday in India commemorating the nation's independence from the United Kingdom on 15 August 1947, the UK Parliament passed the Indian Independence Act 1947 transferring legislative sovereignty to the Indian Constituent Assembly. India still retained King George VI as head of state until its transition to full republican constitution. India attained independence following the Independence Movement noted for largely nonviolent resistance and civil disobedience led by the Indian National Congress (INC). Independence coincided with the partition of India, in which the British India was divided along religious lines into the Dominions of India and Pakistan; the partition was accompanied by violent riots and mass casualties, and the displacement of nearly 15 million people due to religious violence. On 15 August 1947, Jawaharlal Nehru, who had become the first Prime Minister of India that day, raised the Indian national flag above the Lahori Gate of the Red Fort in Delhi. On each subsequent Independence Day, the prime minister customarily raises the flag and gives an address to the nation
- </div>
- </div>
- </body>
- </html>
- --------------------------------------------------------------------
- <!-- Activity 6 drop-down list-->
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- body {
- max-width: 500px;
- margin: auto;
- padding: 300px;
- }
- ul {
- list-style: none;
- padding: 0;
- margin: 0;
- }
- ul li {
- display: block;
- position: relative;
- float: left;
- background: #EAEDED;
- }
- li ul { display: none; }
- ul li a {
- display: block;
- padding: 1em;
- text-decoration: none;
- white-space: nowrap;
- color: black;
- }
- ul li a:hover { background: #D6EAF8; }
- li:hover > ul {
- display: block;
- position: absolute;
- }
- li:hover li { float: none; }
- li:hover a { background: #EAEDED; }
- li:hover li a:hover { background: #D6EAF8; }
- .main-navigation li ul li { border-top: 0; }
- ul ul ul {
- left: 100%;
- top: 0;
- }
- ul:before,
- ul:after {
- content: " "; /* 1 */
- display: table; /* 2 */
- }
- ul:after { clear: both; }
- </style>
- </head>
- <body>
- <ul class="main-navigation">
- <li><a href="#">Home</a></li>
- <li><a href="#">Categories</a>
- <ul>
- <li><a href="#">Photoshop</a></li>
- <li><a href="#">Illustrator</a></li>
- <li><a href="#">Web Design</a>
- <ul>
- <li><a href="#">HTML</a></li>
- <li><a href="#">CSS</a></li>
- </ul>
- </li>
- </ul>
- </li>
- <li><a href="#">Most Popular</a></li>
- <li><a href="#">Contact Us</a></li>
- </ul>
- </li>
- </ul>
- </body>
- </html>
- ----------------------------------------------
- <!-- Activity 7 Calculator html-->
- <!DOCTYPE html>
- <html>
- <head>
- <title>Calculator Project</title>
- <style>
- /* Basic Reset*/
- /* https://meyerweb.com/eric/tools/css/reset/ */
- /* v1.0 | 20080212 */
- html, body, div, span, applet, object, iframe,
- h1, h2, h3, h4, h5, h6, p, blockquote, pre,
- a, abbr, acronym, address, big, cite, code,
- del, dfn, em, font, img, ins, kbd, q, s, samp,
- small, strike, strong, sub, sup, tt, var,
- b, u, i, center,
- dl, dt, dd, ol, ul, li,
- fieldset, form, label, legend,
- table, caption, tbody, tfoot, thead, tr, th, td {
- max-width: 500px;
- margin: auto;
- padding: 70px;
- background: transparent;
- }
- body {
- line-height: 1;
- }
- ul {
- list-style: none;
- }
- body {
- width: 500px;
- }
- form {
- background-color: black;
- text-align: center;
- padding: 7px;
- color:white;
- }
- #display {
- width: 98%;
- height: 30px;
- text-align: right;
- font-size: 1.5rem;
- }
- .digit {
- font-size: 2rem;
- background-color: black;
- color:white;
- height: 55px;
- width: 20%;
- display: inline-block;
- padding: 5px;
- }
- .oper {
- font-size: 2rem;
- background-color: green;
- color:white;
- height: 55px;
- width: 20%;
- border-radius: 5px;
- display: inline-block;
- padding: 5px;
- }
- #C {
- background-color: red;
- }
- #equal {
- background-color: blue;
- }
- </style>
- <script src="Calc.js" type="text/javascript">
- </script>
- </head>
- <body>
- <form name="case">
- <input name="display" id="display" value="">
- <input type="button" class="digit" value="1" onclick="run1()">
- <input type="button" class="digit" value="2" onclick="run2()">
- <input type="button" class="digit" value="3" onclick="run3()">
- <input type="button" id="plus" class="oper" value="+" onclick="runPlus()">
- <input type="button" class="digit" value="4" onclick="run4()">
- <input type="button" class="digit" value="5" onclick="run5()">
- <input type="button" class="digit" value="6" onclick="run6()">
- <input type="button" id="minus" class="oper" value="-" onclick="runMinus()" >
- <input type="button" class="digit" value="7" onclick="run7()">
- <input type="button" class="digit" value="8" onclick="run8()">
- <input type="button" class="digit" value="9" onclick="run9()">
- <input type="button" id="divide" class="oper" value="/" onclick="runDivide()" >
- <input type="button" class="digit" value="0" onclick="run0()">
- <input type="button" id="C" class="oper" value="C" onclick="runC()">
- <input type="button" id="equal" class="oper" value="=" onclick="runEquals()">
- <input type="button" id="multiply" class="oper" value="*" onclick="runMultiply()">
- </div>
- </div>
- </body>
- </html>
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- <!-- Activity 7 Calculator javascript-->
- function run1(){
- document.case.display.value += "1"
- };
- function run2(){
- document.case.display.value += "2"
- };
- function run3(){
- document.case.display.value += "3"
- };
- function run4(){
- document.case.display.value += "4"
- };
- function run5(){
- document.case.display.value += "5"
- };
- function run6(){
- document.case.display.value += "6"
- };
- function run7(){
- document.case.display.value += "7"
- };
- function run8(){
- document.case.display.value += "8"
- };
- function run9(){
- document.case.display.value += "9"
- };
- function run0(){
- document.case.display.value += "0"
- };
- function runPlus(){
- document.case.display.value += "+"
- };
- function runMinus(){
- document.case.display.value += "-"
- };
- function runDivide(){
- document.case.display.value += "/"
- };
- function runMultiply(){
- document.case.display.value += "*"
- };
- function runC(){
- document.case.display.value = ""
- };
- function runEquals() {
- var equals = eval(document.case.display.value)
- document.case.display.value = equals;
- }
- -----------------------------------------------------------
- <!-- Activity 8 Clock -->
- <html>
- <head>
- <title>CLOCK</title>
- <style>
- .clockdate-wrapper {
- background-color: black;
- color:white;
- padding:25px;
- max-width:350px;
- width:100%;
- text-align:center;
- border-radius:5px;
- margin:0 auto;
- margin-top:15%;
- }
- #clock{
- background-color: black;
- color:white;
- font-size:60px;
- }
- #clock span {
- color:white;
- font-size:30px;
- position:relative;
- }
- #date {
- letter-spacing:4px;
- font-size:14px;
- color:red;
- }
- ul{
- display:inline-block;
- list-style:none;
- width:100%
- text-align:center;
- padding:0px;
- margin:0px;
- }
- ul li
- {
- display:inline-block;
- list-style:none;
- }
- .active
- {
- color:#ffff;
- }
- button{
- float:left;
- height:15px;
- }
- input
- {
- width:50px;
- }
- #menu{
- display:none;
- }
- </style>
- <script>
- function startTime() {
- var today = new Date();
- var hr = today.getHours();
- var min = today.getMinutes();
- var sec = today.getSeconds();
- ap = (hr < 12) ? "<span>AM</span>" : "<span>PM</span>";
- hr = (hr == 0) ? 12 : hr;
- hr = (hr > 12) ? hr - 12 : hr;
- if(hr==document.getElementById("h").value)
- if(min==document.getElementById("m").value)
- if(sec==document.getElementById("s").value)
- alert("ALARM");
- //Add a zero in front of numbers<10
- hr = checkTime(hr);
- min = checkTime(min);
- sec = checkTime(sec);
- document.getElementById("clock").innerHTML = hr + ":" + min + ":" + sec + " " + ap;
- var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
- var curWeekDay = days[today.getDay()];
- var date = curWeekDay;
- document.getElementById("date").innerHTML = date;
- var time = setTimeout(function(){ startTime() }, 500);
- day();
- }
- function checkTime(i) {
- if (i < 10) {
- i = "0" + i;
- }
- return i;
- }
- function day()
- {
- var a=document.getElementById("date").innerHTML.substr(0,3);
- document.getElementById("date").innerHTML=document.getElementById("date").innerHTML.substr(5);
- document.getElementById(a).className="active";
- }
- function alarm()
- {
- console.log("ALARM");
- if(document.getElementById("menu").style.display=="none")
- {
- console.log("ALARM2");
- document.getElementById("menu").style.display="block";
- }
- else
- document.getElementById("menu").style.display="none";
- }
- </script>
- </head>
- <body onload="startTime()">
- <div id="clockdate">
- <div class="clockdate-wrapper">
- <div id="day">
- <ul>
- <li id="Mon">Mon</li>
- <li id="Tue">Tue</li>
- <li id="Wed">Wed</li>
- <li id="Thu">Thu</li>
- <li id="Fri">Fri</li>
- <li id="Sat">Sat</li>
- <li id="Sun">Sun</li>
- </ul>
- </div>
- <div id="date"></div>
- <div id="clock"></div>
- <button onclick="alarm()"></button>
- <div id="menu"><ul>
- <li>
- <input id="h"></li>Hours
- <li>
- <input id="m"></li>Minutes
- <li>
- <input id="s"></li>Secs
- </ul>
- </div>
- </div>
- </div>
- -------------------------------------------------------------
- <!-- Activity 9(A) string operations-->
- <!DOCTYPE html>
- <html>
- <head>
- <title> Activity 9(a)</title>
- <style>
- h1{
- text-align:center;
- }
- span{
- font-family:calibri;
- font-size:30px;
- }
- #b{
- height:35px;
- width:470px;
- margin:5px 40px 0px 40px;
- background-color:rgb(200,200,200);
- padding: 2px 2px 6px 8px ;
- border: 1px solid rgb(200,200,200);
- border-radius:4px;
- }
- #a{
- height:35px;
- width:100px;
- font-size:20px;
- }
- </style>
- </head>
- <body>
- <h1> PHP String Operations </h1>
- <form method="post" action="activity-9(a).php">
- <span>First Name</span> <input id="b" type="text" name="first" placeholder="Input your First Name"/><br><br>
- <span>Last Name </span><input id="b" type="text" name="last" placeholder="Input your Last Name"/><br><br>
- <input id="a" type="submit" name="submit" value="submit"><br><br>
- </form>
- <?php
- if(!empty($_POST["first"])&&!empty($_POST["last"]))
- {
- echo "<h2>OUTPUT:</h2>";
- echo "<h4>Uppercase string operation:</h4>";
- echo strtoupper($_POST["first"]);
- echo "<br>";
- echo strtoupper($_POST["last"]);
- echo "<br><br>";
- echo "<h4>Substring Compare string operation:</h4>";
- echo substr_compare($_POST["first"],$_POST["last"],0);
- echo "<br><br>";
- echo "<h4>String Length operation:</h4>";
- echo "Length of First name is = ".strlen($_POST["first"]);
- echo "<br>";
- echo "Length of Last name is = ".strlen($_POST["last"]);
- echo "<br><br>";
- echo "<h4>Substring Replace operation:</h4>";
- echo "First name is = ".substr_replace($_POST["first"],"Hello",0);
- echo "<br>";
- echo "Last name is = ".substr_replace($_POST["last"],"World",0);
- echo "<br><br>";
- echo "<h4>String Reverse operation:</h4>";
- echo "First name is = ".strrev($_POST["first"]);
- echo "<br>";
- echo "Last name is = ".strrev($_POST["last"]);
- echo "<br><br>";
- }
- ?>
- </body>
- </html>
- ----------------------------------------------------------------------
- <!-- Activity 9(B) array operations-->
- <html>
- <body>
- Here are the account holder details:<br><br>
- <?php
- $test =
- array($_POST["name"],$_POST["acc"],$_POST["ifsc"],$_POST["cif"],$_POST["branch"],$_POST["ph"],$_POST["
- add"]);
- echo nl2br ("Name: " . $test[0] . "\n");
- echo nl2br ("Account Number: " . $test[1] . "\n");
- echo nl2br ("IFSC Code: " . $test[2] . "\n");
- echo nl2br ("CIF: " . $test[3] . "\n");
- echo nl2br ("Branch: " . $test[4] . "\n");
- echo nl2br ("Phone Number: " . $test[5] . "\n");
- echo nl2br ("Address: " . $test[6] . "\n");
- ?>
- <br>
- 4 Unique Array Operations:<br><br>
- <b>1. Split an array into chunks of two.</b><br>
- <?php
- print_r(array_chunk($test,2));
- ?>
- <br><br>
- <b>2. Flip all keys with their associated values in an array.</b><br>
- <?php
- $result=array_flip($test);
- print_r($result);
- ?>
- <br><br>
- <b>3. Return an array in the reverse order.</b><br>
- <?php
- print_r(array_reverse($test));
- ?>
- <br><br>
- <b>4. Slice from the third array element, and return the rest of the elements in the array.</b><br>
- <?php
- print_r(array_slice($test,2));
- ?>
- </body>
- </html>
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- <index.text>
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- <html>
- <title>Question - 1</title>
- <body>
- <form action="array_operation.php" method="post">
- Name: <input type="text" name="name"><br>
- Account Number: <input type="text" name="acc"><br>
- IFSC Code: <input type="text" name="ifsc"><br>
- CIF: <input type="text" name="cif"><br>
- Branch: <input type="text" name="branch"><br>
- Phone: <input type="text" name="ph"><br>
- Address: <input type="text" name="add"><br>
- <input type="submit">
- </form>
- </body>
- </html>
- --------------------------------------------------------------------------------------
- <! Activity 10 Form Validation -->
- <!DOCTYPE html>
- <html>
- <head>
- <title>Question - 5</title>
- </head>
- <body bgcolor=#c3c3c3>
- <h3 align="center">Form Validation</h3>
- <hr><br>
- <?php
- $nameErr = $addrErr = $genderErr = $eduErr= "";
- $name = $address = $sex = $edu ="";
- ?>
- <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
- Name:
- <input type="text" name="name">
- <span class="error">* <?php echo $nameErr;?></span>
- <br><br>
- Address:
- <input type="text" name="addr">
- <span class="error">* <?php echo $addrErr;?></span>
- <br><br>
- Gender:
- <input type="radio" name="gender" value="Male">Male
- <input type="radio" name="gender" value="Female">Female
- <span class="error">* <?php echo $genderErr;?></span>
- <br><br>
- Education:
- <textarea name="detail" rows="5" cols="40"></textarea><br><br>
- <hr><br>
- <input type="submit" name="submit" value="Submit">
- </form>
- <?php
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $name = test_input($_POST["name"]);
- $address = test_input($_POST["addr"]);
- $edu = test_input($_POST["detail"]);
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["name"])) {
- $nameErr = "Name is required";
- echo "<br>".$nameErr;
- } else {
- $name = test_input($_POST["name"]);
- if (!preg_match("/^[a-zA-Z ]*$/",$name)) {
- $nameErr = "Only letters and white space allowed";
- }
- }
- if (empty($_POST["addr"])) {
- $addrErr = "Address is required";
- echo "<br>".$addrErr;
- } else {
- $address = test_input($_POST["addr"]);
- if (!preg_match("/^[a-zA-Z ]*$/",$address)) {
- $addrErr = "Invalid email format";
- }
- }
- if (empty($_POST["gender"])) {
- $genderErr = "Gender is required";
- echo "<br>".$genderErr;
- } else {
- $sex = test_input($_POST["gender"]);
- }
- }
- if (empty($_POST["detail"])) {
- $edu = "";
- } else {
- $edu = test_input($_POST["detail"]);
- if (!preg_match("/^[a-zA-Z ]*$/",$edu)) {
- $eduErr = "Only letters and white space allowed";
- }
- }
- ?>
- <br><br>
- <table style="width:100%" border="1">
- <tr>
- <th>Name</th>
- <th>Address</th>
- <th>Gender</th>
- <th>Education</th>
- </tr>
- <tr>
- <td align="center"><?php echo $GLOBALS["name"]; ?></td>
- <td align="center"><?php echo $GLOBALS["address"]; ?></td>
- <td align="center"><?php echo $GLOBALS["sex"]; ?></td>
- <td align="center"><?php echo $GLOBALS["edu"]; ?></td>
- </tr>
- </table>
- </body>
- </html>
- -------------------------------------------------------------------------------
- <!-- Activity 11 (no title so far) -->
- <html>
- <head>
- <title>Question - 3</title>
- </head>
- <body>
- <?php
- if (!($_SERVER["REQUEST_METHOD"] == "POST"))
- {$u="root";
- $p="";
- $db="internet";
- $conn = new mysqli("127.0.0.1", $u, $p);
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $sql = "CREATE DATABASE internet";
- if ($conn->query($sql) === TRUE) {
- echo "Database created successfully<br>";
- } else {
- echo "Error creating database: " . $conn->error;
- }
- $conn->close();
- $conn=new mysqli("127.0.0.1",$u,$p,$db);
- if ($conn->connect_error)
- {
- die("Conneection error :-".$conn->connect_error);
- }
- $sql="CREATE TABLE login (uname VARCHAR(40) PRIMARY KEY,pass VARCHAR(40) NOT NULL)";
- if ($conn->query($sql) === TRUE) {
- echo "Table created successfully<br>";
- } else {
- echo "Error creating table: " . $conn->error;
- }
- $sql = "INSERT INTO login VALUES ('vit', 'batch1')";
- if ($conn->query($sql) === TRUE) {
- echo "New record created successfully<br>";
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- }
- ?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
- <input type="text" name="user" required>
- <input type="text" name="pass" required>
- <input type="submit">
- </form>
- <?php
- if($_SERVER["REQUEST_METHOD"] == "POST")
- {
- $u="root";
- $p="";
- $db="internet";
- $conn=new mysqli("127.0.0.1",$u,$p,$db);
- if ($conn->connect_error)
- {
- die("Connection error :-".$conn->connect_error);
- }
- $user=$_POST['user'];
- $pass=$_POST['pass'];
- $q="SELECT uname,pass from login where uname=$user and pass=$pass";
- $result = $conn->query($q);
- if ($result->num_rows > 0) {
- echo("Welcome ".$user.". Have a nice day!");
- }
- else{
- echo("Invalid username or password");
- }
- }
- ?>
- </body>
- </html>
- ---------------------------------------------------------------------------------------
- <!-- Activity 12 file uploading -->
- <?php
- $target_dir = "uploads/";
- $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
- $uploadOk = 1;
- $FileType = pathinfo($target_file,PATHINFO_EXTENSION);
- if (file_exists($target_file)) {
- echo "Sorry, file already exists.";
- $uploadOk = 0;
- }
- if ($_FILES["fileToUpload"]["size"] > 2048000) {
- echo "Sorry, your file is too large. Only Files upto 2Mb of size allowed";
- $uploadOk = 0;
- }
- if($FileType != "ppt" && $FileType != "pptx" && $FileType != "doc" && $FileType != "docx" && $FileType != "pdf") {
- echo "Sorry, only doc,ppt and pdf files are allowed.";
- $uploadOk = 0;
- }
- if ($uploadOk == 0) {
- echo "Sorry, your file was not uploaded.";
- } else {
- if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
- echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.";
- } else {
- echo "Sorry, there was an error uploading your file.";
- }
- }
- ?>
- ---------------------------------------------------------------------------------------
- <!-- Activity 13 file handling -->
- (php part)
- <?php
- $myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
- $first = $_POST["first"];
- $second = $_POST["second"];
- fwrite($myfile, $first);
- fwrite($myfile, $second);
- fclose($myfile);
- echo "Data added to the file<br>";
- $file = fopen("newfile.txt","r");
- $c=0;
- while(! feof($file))
- {
- $c=$c+1;
- echo fgets($file). "<br />";
- }
- $size1=filesize("newfile.txt");
- echo "<br> Number of lines - $c";
- echo "<br> File size = $size1";
- fclose($file);
- ?>
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- (form)
- <!DOCTYPE html>
- <html>
- <head>
- <title> Activity 13</title>
- <style>
- h1{
- text-align:center;
- }
- span{
- font-family:calibri;
- font-size:30px;
- }
- #b{
- height:35px;
- width:470px;
- margin:5px 40px 0px 40px;
- background-color:rgb(200,200,200);
- padding: 2px 2px 6px 8px ;
- border: 1px solid rgb(200,200,200);
- border-radius:4px;
- }
- #a{
- height:35px;
- width:100px;
- font-size:20px;
- }
- </style>
- </head>
- <body>
- <h1> PHP File Operations </h1>
- <form method="post" action="activity-13.php">
- <span>First Name</span> <input id="b" type="text" name="first" placeholder="Input your First Name"/><br><br>
- <span>Second Name </span><input id="b" type="text" name="second" placeholder="Input your Last Name"/><br><br>
- <input id="a" type="submit" name="submit" value="submit"><br><br>
- </form>
- <body>
- </html>
- -----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement