Guest User

Untitled

a guest
Mar 11th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.80 KB | None | 0 0
  1. WEB TECHNOLOGIES LABORATORY
  2. OBJECTIVE:
  3. Presenting information over internet in form of web pages is the best way of reaching to
  4. all corners of world. This laboratory aims at giving knowledge about creating web pages and also
  5. about different web programming concepts, technologies.
  6. OUTCOMES:
  7. Upon the completion of Operating Systems practical course, the student will be able to:
  8. 1. Demonstrate the ability to retrieve data from a database and present it in a web page.
  9. 2. Demonstrate competency in the use of common HTML code.
  10. 3. Demonstrate competency using FTP to transfer web pages to a server.
  11. 4. Construct pages that meet guidelines for efficient download.
  12. 5. Construct pages that meet the needs of an identified audience.
  13. 6. Construct efficient file structure for web sites.
  14. 7. Evaluate the functions of specific types of web pages in relationship to an entire web site.
  15. 8. Design electronic text and web pages that include the standard textual components needed
  16. on web pages.
  17. 9. Create web pages that meet accessibility needs of those with physical disabilities.
  18. 10. Understand how CSS will affect web page creation.
  19. 27 | P a g eEXPERIMENT-1
  20. OBJECTIVE:
  21. To Install XAMPP Stack Server.
  22. RESOURCES:
  23. XAMPP Stack Software, 1GB RAM, Hard Disk 80 GB.
  24. PROCEDURE:
  25. 1. Run the XAMPP setup software.
  26. 2. In the next Screen, Select the path if required and then click on the Next Button.
  27. 27 | P a g e3. In the next screen select Apache and MySQL. You may optionally select FileZilla
  28. (FTP Client) if needed. Click Install.
  29. 4. On successful completion of installation, the following window will appear.
  30. 27 | P a g e5. Click on Finish button.
  31. INPUT AND OUTPUT:
  32. 27 | P a g ePRE LAB VIVA QUESTIONS:
  33. 1. What is XAMPP stack?
  34. 2. What is setup file?
  35. 3. What is client side scripting?
  36. 4. What is server side scripting?
  37. LAB ASSIGNMENT:
  38. 1. Install WAMP Stack Server?
  39. 2. Install LAMP Stack Server?
  40. POST LAB VIVA QUESTIONS:
  41. 1. What is Mysql?
  42. 2. Why is the name as Mysql?
  43. 3. What is the usage of apache tomcat server?
  44. 4. How to run the PHP file?
  45. 27 | P a g eEXPERIMENT-2
  46. OBJECTIVE:
  47. To accept a number from one text field in the range of 0 to 999 and shows it in another text field
  48. in words. If the number is out of range, it should show “out of range” and if it is not a number, it
  49. should show “not a number” message in the result box.
  50. RESOURCES:
  51. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  52. PROGRAM LOGIC:
  53. 1. Create a HTML file.
  54. 2. Read a number in one text field and display that number name in another text field.
  55. 3. Include the JavaScript to convert number into words.
  56. PROCEDURE:
  57. To execute a PHP program:
  58. 1. Open XAMPP control Panel then start Apache Server and Mysql.
  59. 2. Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  60. 3. To run the php file open the browser and type the following URL
  61. localhost:90/directory name/filename
  62. SOURCE CODE:
  63. <html>
  64. <head>
  65. <script type="text/javascript">
  66. var th = ['','thousand','million', 'billion','trillion'];
  67. var dg=['zero','one','two','three','four','five','six','seven','eight','nine'];
  68. var tn=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'];
  69. var tw=['twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'];
  70. function change()
  71. {
  72. var numString=document.getElementById('anumber').value;
  73. var output=towords(numString);
  74. 27 | P a g edocument.getElementById('aresult').value=output;
  75. }
  76. function towords(s)
  77. {
  78. s = s.toString();
  79. if (s != parseFloat(s)) return 'not a number';
  80. var x = s.indexOf('.');
  81. if (x == -1) x = s.length;
  82. if (x > 3) return 'too big';
  83. var n = s.split('');
  84. var str = '';
  85. var sk = 0;
  86. for (var i=0; i < x; i++)
  87. {
  88. if ((x-i)%3==2)
  89. {
  90. if (n[i] == '1')
  91. {
  92. str += tn[Number(n[i+1])] + ' ';
  93. i++;
  94. sk=1;
  95. }
  96. else if (n[i]!=0)
  97. {
  98. str += tw[n[i]-2] + ' ';
  99. sk=1;
  100. }
  101. }
  102. else if (n[i]!=0)
  103. {
  104. str += dg[n[i]] +' ';
  105. if ((x-i)%3==0) str += 'hundred ';
  106. sk=1;
  107. 27 | P a g e}
  108. if ((x-i)%3==1)
  109. {
  110. if (sk) str += th[(x-i-1)/3] + ' ';
  111. sk=0;
  112. }
  113. }
  114. return str;
  115. }
  116. </script>
  117. </head>
  118. <body>
  119. <form>
  120. enter a number<input type="text" id="anumber">
  121. <input type="button" value='convert to words' onClick="change()">
  122. <input type="text" size="40" id="aresult">
  123. </form>
  124. </body>
  125. </html>
  126. INPUT AND OUTPUT:
  127. 27 | P a g ePRE LAB VIVA QUESTIONS:
  128. 1. What is an example of client side scripting language?
  129. 2. What are JavaScript data types?
  130. 3. How do we submit the form in JavaScript?
  131. 4. What is JavaScript?
  132. LAB ASSIGNMENT:
  133. 1. Write a JavaScript program for checking a number is even or odd?
  134. 2. Write a JavaScript program for a string is palindrome or not?
  135. 3. Write a JavaScript program for printing the days of a week?
  136. POST LAB VIVA QUESTIONS:
  137. 1. How to create the text field?
  138. 2. How to retrieve the form data?
  139. 3. What is the purpose of writing document.getElementById ('anumber').value?
  140. 4. How to create an array in JavaScript?
  141. 27 | P a g eEXPERIMENT-3
  142. OBJECTIVE:
  143. To display the number lines ,words and characters from an HTML page that has one input, which
  144. can take multi-line text and a submit button. Once the user clicks the submit button, it should
  145. show the number of characters, words and lines in the text entered using an alert message. Words
  146. are separated with a white space and lines are separated with new line character.
  147. RESOURCES:
  148. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  149. PROGRAM LOGIC:
  150. 1. Create an HTML File to read the multi-line text using text area field.
  151. 2. Once the user clicks the submit button it should show the number of characters ,words and lines
  152. entered in the text area.
  153. 3. Include the JavaScript code to count the number of characters, words and lines.
  154. PROCEDURE:
  155. To execute a PHP program:
  156. 1.Open XAMPP control Panel then start Apache Server and Mysql.
  157. 2.Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  158. 3.To run the php file open the browser and type the following URL
  159. localhost:90/directory name/filename
  160. SOURCE CODE:
  161. <html>
  162. <head>
  163. <script type="text/JavaScript">
  164. function count()
  165. {
  166. var str=document.getElementById('atext').value;
  167. var result='';
  168. result+='The number of characters are'+str.length+'\n';
  169. var arr=str.split(' ');
  170. result+='The number of words are'+arr.length+'\n';
  171. var a=str.split('\n');
  172. 27 | P a g eresult+='The number of lines are'+a.length;
  173. alert(result);
  174. }
  175. </script>
  176. </head>
  177. <body>
  178. <form>
  179. <textarea rows='40' cols='70' id='atext'>
  180. </textarea>
  181. <input type="submit" value="submit" onclick="count()">
  182. </form>
  183. </body>
  184. </html>
  185. INPUT AND OUTPUT:
  186. PRE LAB VIVA QUESTIONS:
  187. 1. How to create the HTML document?
  188. 2. How to create the text area in an HTML document?
  189. 3. How to create the submit button in an HTML document?
  190. 27 | P a g e4. How to create function in an HTML document?
  191. LAB ASSIGNMENT:
  192. 1. Write an HTML program for creating two frames?
  193. 2. Write a HTML program for adding images with HTML.
  194. 3. Write a HTML Program to demonstrate Cell Spacing and Cell Padding in a XHTML Table?
  195. POST LAB VIVA QUESTIONS:
  196. 1. What is the purpose of str.split(' ')?
  197. 2. What is the purpose of str.split('\n')?
  198. 3. How to find the length of the array?
  199. 4. How to create the alert message?
  200. 27 | P a g eEXPERIMENT-4
  201. OBJECTIVE:
  202. To print the capital of country from HTML page that contains a selection box with a list of 5
  203. countries. When the user selects a country, its capital should be printed next to the list. Add CSS
  204. to customize the properties of the font of the capital (color, bold and font size)
  205. RESOURCES:
  206. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  207. PROGRAM LOGIC:
  208. 1. Create an HTML file from which select the country from the selection box.
  209. 2. Once the user selects the country it should display the selected country’s capital.
  210. 3. Include the JavaScript display the capital for selected country.
  211. 4. Create the CSS file which includes the properties like color, bold and font size.
  212. PROCEDURE:
  213. To execute a PHP program:
  214. 1.Open XAMPP control Panel then start Apache Server and Mysql.
  215. 2.Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  216. 3.To run the php file open the browser and type the following URL
  217. localhost:90/directory name/filename
  218. SOURCE CODE:
  219. <html>
  220. <title>Fourth Program</title>
  221. <head>
  222. <script type="text/JavaScript">
  223. function OnDropDownChange(dropDown)
  224. {
  225. var selectedValue = dropDown.options[dropDown.selectedIndex].value;
  226. document.getElementById("txtSelectedCapital").innerHTML = selectedValue;
  227. }
  228. </script>
  229. </head>
  230. <body>
  231. 27 | P a g e<form action = "">
  232. <select name = "Countries" onChange="OnDropDownChange(this);">
  233. <option value="">--Select a country--</option>
  234. <option value="New Delhi">India</option>
  235. <option value="Wellington">New Zealand</option>
  236. <option value="Paris">France</option>
  237. <option value="Athens">Greece</option>
  238. <option value="Madrid">Spain</option>
  239. </select>
  240. <h1
  241. style="color:blue;font-family:verdana;font-size:300%;"
  242. id="txtSelectedCapital"
  243. type="text"></h1>
  244. </form>
  245. </body>
  246. </html>
  247. INPUT AND OUTPUT:
  248. 27 | P a g ePRE LAB VIVA QUESTIONS:
  249. 1. How do you insert a comment in html?
  250. 2. What are some of the common lists that can be used when designing a page?
  251. 3. How do you create links to sections within the same page?
  252. 4. Does a hyperlink apply to text only?
  253. LAB ASSIGNMENT:
  254. 1. Write a HTML Program to demonstrate Form Fields.
  255. 2. Write a HTML Demonstration of Navigation through various frames
  256. 3. To create a php program to demonstrate the different file handling methods.
  257. POST LAB VIVA QUESTIONS:
  258. 1. If the user’s operating system does not support the needed character, how can the symbol be
  259. represented?
  260. 2. How do you change the number type in the middle of a list?
  261. 3. Is it possible to set specific colors for table borders?
  262. 4. How do you create a link that will connect to another web page when clicked?
  263. 27 | P a g eEXPERIMENT-5
  264. OBJECTIVE:
  265. To write a program that parses an XML document using DOM and SAX parsers.
  266. RESOURCES:
  267. JDK Tool Kit, 1GB RAM, Hard Disk 80 GB
  268. PROGRAM LOGIC:
  269. 1. Create a .xml file that has to be parsed.
  270. 2. Using DOM parser
  271. i. Get a document builder using document builder factory and parse the xml file to create a
  272. DOM object
  273. ii. Get a list of User elements from the DOM
  274. iii. For each User element id get the name, age and qualification.
  275. 3. Using SAX Parser
  276. Create a Sax parser and parse the xml
  277. In the event handler create the User object
  278. Print out the data
  279. PROCEDURE:
  280. To execute a java program we require setting a class path:
  281. 1.C:\set path= C:\Program Files\Java\jdk1.6.0\bin;.;
  282. 2.C:\javac Parse.java
  283. 3. C:\java Parse
  284. SOURCE
  285. CODE:
  286. DOM:
  287. Student.xml
  288. <?xml version="1.0"?>
  289. <student>
  290. <Roll_No>10</Roll_No>
  291. <Personal_Info>
  292. <Name>parth</Name>
  293. <Address>pune</Address>
  294. <Phone>1234567890</Phone>
  295. </Personal_Info>
  296. <Class>Second</Class>
  297. <Subject>Maths</Subject><Marks>100</Marks>
  298. 27 | P a g e27 | P a g e<Roll_No>20</Roll_No>
  299. <Personal_Info>
  300. <Name>AnuRadha</Name>
  301. <Address>Bangalore</Address>
  302. <Phone>90901233</Phone>
  303. </Personal_Info>
  304. <Class>Fifth</Class>
  305. <Subject>English</Subject>
  306. <Marks>90</Marks>
  307. <Roll_No>30</Roll_No>
  308. <Personal_Info>
  309. <Name>Anand</Name>
  310. <Address>Mumbai</Address>
  311. <Phone>90901256</Phone>
  312. </Personal_Info>
  313. <Class>Fifth</Class>
  314. <Subject>English</Subject>
  315. <Marks>90</Marks>
  316. </student>
  317. Parse.java
  318. import java.io.*;
  319. import javax.xml.parsers.*;
  320. import org.w3c.dom.*;
  321. import org.xml.sax.*;
  322. public class Parse
  323. {
  324. public static void main(String[] arg)
  325. {
  326. try
  327. {
  328. System.out.println("enter the name of xml document");
  329. BufferedReader input=new BufferedReader(new InputStreamReader(System.in));
  330. String file_name=input.readLine();
  331. File fp=new File(file_name);
  332. if(fp.exists())
  333. 27 | P a g e{
  334. try
  335. {
  336. DocumentBuilderFactory Factory_obj=DocumentBuilderFactory.newInstance();
  337. DocumentBuilder builder=Factory_obj.newDocumentBuilder();
  338. InputSource ip_src=new InputSource(file_name);
  339. Document doc=builder.parse(ip_src);
  340. System.out.println(file_name+" is well-formed!");
  341. }
  342. catch(Exception e)
  343. {
  344. System.out.println(file_name+" isn't well-formed!");
  345. System.exit(1);
  346. }
  347. }
  348. else
  349. {
  350. System.out.print("file not found!");
  351. }
  352. }
  353. catch(IOException ex)
  354. {
  355. ex.printStackTrace();
  356. }
  357. }}
  358. SAX:
  359. EmployeeDetail.xml:
  360. <?xml version="1.0"?>
  361. <EmployeeDetail>
  362. <Employee>
  363. <Emp_id>E-001</Emp_id>
  364. <Emp_Name>revathy</Emp_Name>
  365. <Emp_E-mail>revathy@yahoo.com</Emp_E-mail>
  366. </Employee>
  367. <Employee>
  368. 27 | P a g e<Emp_id>E-002</Emp_id>
  369. <Emp_Name>vinod</Emp_Name>
  370. <Emp_E-mail>vinod2@yahoo.com</Emp_E-mail>
  371. </Employee>
  372. <Employee>
  373. <Emp_id>E-001</Emp_id>
  374. <Emp_Name>deepak</Emp_Name>
  375. <Emp_E-mail>deepak3@yahoo.com</Emp_E-mail>
  376. </Employee>
  377. </EmployeeDetail>
  378. SAXParserCheck.java:
  379. import org.xml.sax.*;
  380. import org.xml.sax.helpers.*;
  381. import java.io.*;
  382. public class SAXParserCheck
  383. {
  384. public static void main(String[]args)throws IOException
  385. {
  386. BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
  387. System.out.print("enter XML file name :");
  388. String xmlfile=bf.readLine();
  389. SAXParserCheck par=new SAXParserCheck(xmlfile);
  390. }
  391. public SAXParserCheck(String str)
  392. {
  393. try
  394. {
  395. File file=new File(str);
  396. if(file.exists())
  397. {
  398. XMLReader reader=XMLReaderFactory.createXMLReader();
  399. reader.parse(str);
  400. System.out.println(str+" is well-formed!");
  401. }
  402. else
  403. 27 | P a g e{
  404. System.out.println("File not found:"+str);
  405. }
  406. }
  407. catch(SAXException sax)
  408. {
  409. System.out.println(str+" isn't well-formed");
  410. }
  411. catch(IOException io)
  412. {
  413. System.out.println(str+" isn't well-formed");
  414. }
  415. INPUT AND
  416. OUTPUT: DOM:
  417. SAX:
  418. 27 | P a g ePRE LAB VIVA QUESTIONS:
  419. 1. Is Java purely object oriented language?
  420. 2. How to create an object in java language?
  421. 3. How to display the string in java language?
  422. 4. What is the purpose of java.io.* package?
  423. LAB ASSIGNMENT:
  424. 1. Write a program to reverse a number using Java language?
  425. 2. Write a program for linear search using Java language?
  426. 3. Write a program to check a number is even or odd using Java language?
  427. POST LAB VIVA QUESTIONS:
  428. 1. How to handle the exceptions in java?
  429. 2. How to catch exceptions using java language?
  430. 3. How to read the XML file using java language?
  431. 4. How many types of parsers we have in XML?
  432. 27 | P a g eEXPERIMENT-6
  433. OBJECTIVE:
  434. To validate the user login using PHP and database.
  435. RESOURCES:
  436. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  437. PROGRAM LOGIC:
  438. 1. Create the user database and table along with the user name and password as the attributes.
  439. 2. Create an HTML File to retrieve user name and password.
  440. 3. Create PHP file to retrieve the data from the database and HTML File.
  441. 4. Authenticate the user name and password if it is the valid user the display as successful login
  442. otherwise display failure message.
  443. PROCEDURE:
  444. To execute a PHP program:
  445. 1. Open XAMPP control Panel then start Apache Server and Mysql.
  446. 2. Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  447. 3. To run the php file open the browser and type the following URL
  448. localhost:90/directory name/filename
  449. SOURCE CODE:
  450. <html>
  451. <body>
  452. <form enctype="multipart/form-data" action="database.php" method="post">
  453. username:
  454. <input type="text" name="username">
  455. <br>
  456. password:
  457. <input type="password" name="password" maxlength="10">
  458. <br>
  459. <input type="submit" name="submit">
  460. </form>
  461. </body>
  462. </html>
  463. database.php
  464. 27 | P a g e<?php
  465. $name=$_REQUEST['username'];
  466. $pass=$_REQUEST['password'];
  467. $dbhost = 'localhost';
  468. $dbuser = 'root';
  469. $dbpass = 'santosh';
  470. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  471. if(! $conn ) {
  472. die('Could not connect: ' . mysql_error());
  473. }
  474. $sql = 'SELECT username, password FROM user_detail';
  475. mysql_select_db('user_login');
  476. $retval = mysql_query( $sql, $conn );
  477. if(! $retval ) {
  478. die('Could not get data: ' . mysql_error());
  479. }
  480. while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
  481. {
  482. if($name==$row['username'] && $pass==$row['password'])
  483. {
  484. echo("login sucesses");
  485. return true;
  486. }
  487. else
  488. {
  489. echo("invalid username and paasword ");
  490. return false;
  491. }
  492. }
  493. ?>
  494. 27 | P a g e27 | P a g eINPUT AND OUTPUT:
  495. PRE LAB VIVA QUESTIONS:
  496. 1. What does the initials of PHP stand for?
  497. 2. Which programming language does PHP resemble to?
  498. 3. What is the actually used PHP version?
  499. 4. How do you execute a PHP script from the command line?
  500. 5. How can PHP and HTML interact?
  501. LAB ASSIGNMENT:
  502. 1.Write a HTML program to demonstrate HTML Headers.
  503. 2.Write a HTML program using images as link Anchor.
  504. 3.Write a HTML program for adding images with HTML.
  505. POST LAB VIVA QUESTIONS:
  506. 1. What is the difference between SQL and Mysql?
  507. 2. What is JOIN in MySQL? What are the different types of join?
  508. 3. If we use SUM function in MySQL, does it return sum of that row or for that column?
  509. 4. What do we use to remove duplicate records while fetching a data in MySQL?
  510. 27 | P a g eEXPERIMENT-7
  511. OBJECTIVE:
  512. To validate the user login using PHP and XML.
  513. RESOURCES:
  514. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  515. PROGRAM LOGIC:
  516. 1. Create the XML file with the tags user name and password.
  517. 2. Create an HTML File to retrieve user name and password.
  518. 3. Create PHP file to retrieve the data from the XML and HTML File.
  519. 4. Authenticate the user name and password if it is the valid user the display as successful login
  520. otherwise display failure message.
  521. PROCEDURE:
  522. To execute a PHP program:
  523. 1. Open XAMPP control Panel then start Apache Server and Mysql.
  524. 2. Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  525. 3. To run the php file open the browser and type the following URL
  526. localhost:90/directory name/filename
  527. SOURCE
  528. CODE: html
  529. file
  530. <html>
  531. <body>
  532. <form action="database.php" method="post">
  533. username:
  534. <input type="text" name="username">
  535. <br>
  536. password:
  537. <input type="password" name="password" maxlength="10">
  538. <br>
  539. <input type="submit" name="submit">
  540. </form>
  541. </body></html>
  542. 27 | P a g exml file-file.xml
  543. <?xml version=”1.0”?>
  544. <user-detail>
  545. <username>santosh</username>
  546. <password>iare</password>
  547. </user-detail>
  548. php file
  549. <?php
  550. $name=$_REQUEST['username'];
  551. $pass=$_REQUEST['password'];
  552. $file=”file.xml”;
  553. $xml=simplexml_load_file($file);
  554. If($name==$xml->username && $pass==$xml->password)
  555. {
  556. echo("login sucesses");
  557. return true;
  558. }
  559. Else
  560. {
  561. echo("invalid username and paasword ");
  562. return false;
  563. }
  564. ?>
  565. INPUT AND OUTPUT:
  566. 27 | P a g ePRE LAB VIVA QUESTIONS:
  567. 1. Whether root element is required for XML? If so, how many root elements are required?
  568. 2. What are the disadvantages of xml?
  569. 3. Is there a way to describe XML data?
  570. 4. What is well formed XML document?
  571. LAB ASSIGNMENT:
  572. 1. Write a program to create a CD catalog using XML file.
  573. 2. To create an XSL style sheet to display the data in the xml using html table.
  574. 3. Write an XML file which will display the Book information.
  575. It includes the following:
  576. 1) Title of the book
  577. 2) Author Name
  578. 3) ISBN number
  579. 4) Publisher name
  580. 5) Edition
  581. 6) Price
  582. Write an Internal Document Type Definition (DTD) to validate the above XML file.
  583. POST LAB VIVA QUESTIONS:
  584. 1. How to read the data from the controls.
  585. 2. Why do we use multipart/form-data in html form?
  586. 3. What function do we use to find length of string, and length of array?
  587. 4. How to display the form data in php?
  588. 27 | P a g eEXPERIMENT-8
  589. OBJECTIVE:
  590. To develop simple calculator web application.
  591. RESOURCES:
  592. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  593. PROGRAM LOGIC:
  594. 1.Create an HTML file to read two variables and operator.
  595. 2.Create an PHP file to compute the arithmetic operation.
  596. 3.Dispaly the result.
  597. PROCEDURE:
  598. To execute a PHP program:
  599. 1. Open XAMPP control Panel then start Apache Server and Mysql.
  600. 2. Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  601. 3. To run the php file open the browser and type the following URL
  602. localhost:90/directory name/filename
  603. SOURCE CODE:
  604. cal.html
  605. <html>
  606. <body>
  607. <form method="POST" action="process.php">
  608. NO1:
  609. <input type="text" name="num1" id="num1">
  610. <br>
  611. NO2:
  612. <input type="text" name="num2" id="num2">
  613. <br>
  614. <select name = "func">
  615. <option value="+">Add [+]</option>
  616. <option value="-">Subtract[-]</option>
  617. <option value="*">Multiple[*]</option>
  618. <option value="/">Divide[/]</option>
  619. 30<option value=”%”>modulus</option>
  620. </select>
  621. <input type="submit" name="submit" value="Submit" >
  622. </form
  623. </body>
  624. </html>
  625. process.php
  626. <?php
  627. $num1 = ($_POST['num1']);
  628. $num2 = ($_POST['num2']);
  629. $func= ($_POST['func']);
  630. if(is_numeric($num1) &&is_numeric($num2) )
  631. {
  632. if($func != null)
  633. {
  634. switch($func)
  635. {
  636. case "+" : $result= $num1 + $num2; break;
  637. case "-" : $result= $num1 - $num2; break;
  638. case "*" : $result= $num1 * $num2; break;
  639. case "/" : $result= $num1 / $num2; break;
  640. case "%" : $result= $num1 % $num2; break;
  641. }
  642. echo("calculation result: ". $result);
  643. }
  644. }
  645. ?>
  646. 31INPUT AND OUTPUT:
  647. PRE LAB VIVA QUESTIONS:
  648. 1. What are arithmetic operations in PHP?
  649. 2. How can we change the value of a constant?
  650. 3. Differences between GET, POST and REQUEST methods ?
  651. 4. What is Open Source Software?
  652. LAB ASSIGNMENT:
  653. 1. A program to store and display student marks using arrays.
  654. 2. Write a HTML Program to demonstrate different forms of Lists- Ordered, Unordered, Nested
  655. and description lists
  656. 3. Write a HTML Demonstration of Navigation through various frames
  657. POST LAB VIVA QUESTIONS:
  658. 1. How to read the data using form controls?
  659. 2. How to use the switch case in PHP?
  660. 3. What is the purpose of ($_POST['num1'])?
  661. 4. What is the purpose of ($_POST['num2'])?
  662. | P a g eEXPERIMENT-9
  663. OBJECTIVE:
  664. To validate age attribute, if age is less than 18 then display a message the user is not authorized to
  665. visit this site otherwise a welcome message should be displayed using PHP.
  666. RESOURCES:
  667. XAMPP Stack, 1GB RAM, Hard Disk 80 GB
  668. PROGRAM LOGIC:
  669. 1Create an HTML file to read the age and username.
  670. 2. Create a PHP file to check the user age.
  671. 3. If age>18 then display a message, welcome to the site otherwise display not authorized to this
  672. site.
  673. PROCEDURE:
  674. To execute a PHP program:
  675. 1.Open XAMPP control Panel then start Apache Server and Mysql.
  676. 2.Open Notepad++ and Save the php program in htdocs folder of XAMPP.
  677. 3.To run the php file open the browser and type the following URL
  678. localhost:90/directory name/filename
  679. SOURCE
  680. CODE: age
  681. checking
  682. <html>
  683. <body>
  684. <form action="age.php" method="post">
  685. username:
  686. <input type="text" name="username">
  687. <br>
  688. password:
  689. <input type="number" name="age" maxlength="10">
  690. <br>
  691. <input type="submit" name="submit">
  692. </form>
  693. | P a g e| P a g e</body>
  694. </html>
  695. age.php
  696. <?php
  697. $name=$_REQUEST['username'];
  698. $age=$_REQUEST['age'];
  699. if($age<=18)
  700. {
  701. echo("hello!".$name.".not authorized to visit this site");
  702. }
  703. else
  704. {
  705. echo("hello!".$name.".welcome to this site");
  706. }
  707. ?>
  708. INPUT AND OUTPUT:
  709. | P a g ePRE LAB VIVA QUESTIONS:
  710. 1. Explain how to submit form without a submit button.
  711. 2. How can we encrypt the password using PHP?
  712. 3. What is the difference between $message and $$message?
  713. 4. Is PHP a loosely Typed Language? What is the difference between strongly typed and loosely
  714. typed language?
  715. LAB ASSIGNMENT:
  716. 1. Write a PHP program for reversing the string?
  717. 2. Write a PHP program for creating feedback Form?
  718. 3. Write a PHP program for creating registration form?
  719. POST LAB VIVA QUESTIONS:
  720. 1. How will you create a database using PHP and MySQL?
  721. 2. How will you find out the value of current session id?
  722. 3. List the different run time errors in PHP.
  723. 4. What is a PHP Session?
  724. | P a g e
Add Comment
Please, Sign In to add comment