Utkarshini

Untitled

Oct 31st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.71 KB | None | 0 0
  1. Demonstrate applying CSS properties to HTML pages with the following examples: 1. Sign in Page
  2. <!DOCTYPE HTML>
  3. <html>
  4. <style>
  5. html{
  6. background-color:#002F5C;
  7. } input[type=text], select {
  8. width: 100%;
  9. padding: 12px 20px;
  10. margin: 8px 0;
  11. display: inline-block;
  12. border: 1px solid #ccc;
  13. border-radius: 4px;
  14. box-sizing: border-box;
  15. } input[type=submit] {
  16. width: 50%;
  17. background-color: #4CAF50;
  18. color: white;
  19. padding: 14px 20px;
  20. margin: 8px 0;
  21. border: none;
  22. border-radius: 4px;
  23. cursor: pointer;
  24. }
  25. button {
  26. width: 40%;
  27. background-color:#002F5C;
  28. color: white;
  29. padding: 14px 20px;
  30. margin: 8px 0;
  31. border: none;
  32. border-radius: 4px;
  33. cursor: pointer;
  34. }
  35. .t{
  36. background-color: #0E0E7B;
  37. padding: 20px;
  38. }
  39. .t{
  40. margin: 0 auto;
  41. width: 500px
  42. }
  43. </style>
  44. <body>
  45. <div>
  46. <form>
  47. <font color="white" /font>
  48. <fieldset class='t'>
  49. <h3 align="center"> SIGN IN </h3>
  50. <input type="text" id="Name" name="Name" placeholder="User Name or Email"><br>
  51. <br>
  52. <input type="text" id="Password" name="Password" placeholder="User Password"><br>
  53. <br>
  54. <input type="submit" value="LOGIN" name="log"><br>
  55. <br>
  56. <input type="checkbox"><align="left">Remember me</align>
  57. <align="right">Forgot password?<br></align>
  58. <br>
  59. <button>Login with Facebook</button>
  60. <button>Login with Twitter</button>
  61. <br>
  62. <br>
  63. Need new account?
  64. <input type="submit" value="Sign up">
  65. </fieldset>
  66. </form>
  67. </div>
  68. </body>
  69. </html>
  70.  
  71. 1.Create a User Registration form with First Name, Last name, address, City, State, Country, Pincode, Username and Password fields for a General login webpage and satisfy the following criteria. Create a validate ( ) function that does the following:
  72. (a) Checks that the First Name, Last Name, City, Country, Username, and Password1 fields are filled out.
  73. (b) Checks that the Pincodeis exactly 6 numeric’s.
  74. (c) Checks that the state is exactly two characters.
  75. (d) Checks that the email is a valid email address.
  76. • false if email has fewer than 6 characters
  77. • false if email does not contain an @ symbol
  78. • false if email does not contain a period (.)
  79. • true otherwise
  80. Solution:
  81. HTML Code:
  82. <html>
  83. <head>
  84. <script type="text/javascript" src="validate.js"></script>
  85. </head>
  86. <body>
  87. <form action="#" name="UserRegistration" onsubmit="return(validate());">
  88. <center><font size=4><b>User Registration Form</b></font></center>
  89. <center><font size=3><b>first name</b></font>
  90. <input type="text" name="fname" id="fname" size="30"><br>
  91. <b>Last Name</b>
  92. <input type="text" name="lname" id="lname" size="30"><br>
  93. <b>address</b>
  94. <input type="text" name="address" id="address" size="30"><br>
  95. <b>City</b>
  96. <input type="text" name="city" id="city" size="30"><br>
  97. <b>state</b>
  98. <input type="text" name="state" id="state" size="30"><br>
  99. <b>Country</b>
  100. <select name="country">
  101. <option value="-1" selected>select..</option>
  102. <option value="India">India</option>
  103. <option value="US">US</option>
  104. <option value="England">England</option>
  105. <option value="China">China</option>
  106. </select><br>
  107. <b>PinCode</b>
  108. <input type="text" name="pincode" id="pincode" size="30"><br>
  109. <b>username</b>
  110. <input type="text" name="username" id="username" size="30"><br>
  111. <b>Password</b>
  112. <input type="password" name="password" id="password" size="30"><br>
  113. <b>EmailId/</b>
  114. <input type="text" name="emailid" id="emailid" size="30"><br>
  115. <input type="reset">
  116. <input type="submit" value="Submit Form" /></center>
  117. </form>
  118. </body>
  119. </html>
  120.  
  121. JaVaSCRIPT CODE:
  122. function validate()
  123. {
  124. if( document.UserRegistration.fname.value == "" )
  125. {
  126. alert( "Please provide your First Name!" );
  127. document.UserRegistration.fname.focus() ;
  128. return false;
  129. }
  130. if( document.UserRegistration.lname.value == "" )
  131. {
  132. alert( "Please provide your Last Name!" );
  133. document.UserRegistration.lname.focus() ;
  134. return false;
  135. }
  136. if( document.UserRegistration.address.value == "" )
  137. {
  138. alert( "Please provide your address!" );
  139. document.UserRegistration.address.focus() ;
  140. return false;
  141. }
  142. if( document.UserRegistration.city.value == "" )
  143. {
  144. alert( "Please provide your city!" );
  145. document.UserRegistration.city.focus() ;
  146. return false;
  147. }
  148. if( document.UserRegistration.state.value == "" || document.UserRegistration.state.value.length != 2)
  149. {
  150. alert( "Please provide your State correct !" );
  151. document.UserRegistration.state.focus() ;
  152. return false;
  153. }
  154. if( document.UserRegistration.country.value == "-1" )
  155. {
  156. alert( "Please provide your country!" );
  157. document.UserRegistration.country.focus() ;
  158. return false;
  159. }
  160. if( document.UserRegistration.pincode.value == "" || isNaN( document.UserRegistration.pincode.value) || document.UserRegistration.pincode.value.length != 6 )
  161. {
  162. alert( "Please provide a pincode in the format ######." );
  163. document.UserRegistration.pincode.focus() ;
  164. return false;
  165. }
  166. if( document.UserRegistration.username.value == "" )
  167. {
  168. alert( "Please provide your User Name!" );
  169. document.UserRegistration.username.focus() ;
  170. return false;
  171. }
  172. if( document.UserRegistration.password.value == "" )
  173. {
  174. alert( "Please provide your Password!" );
  175. document.UserRegistration.password.focus() ;
  176. return false;
  177. }
  178. var email = document.UserRegistration.emailid.value;
  179. atpos = email.indexOf("@");
  180. dotpos = email.lastIndexOf(".");
  181. if (email == "" || email.length <6 || atpos < 1 || ( dotpos - atpos < 2 ))
  182. {
  183. alert("Please enter correct email ID")
  184. document.UserRegistration.emailid.focus() ;
  185. return false;
  186. }
  187. return( true );
  188.  
  189. 2. Create a page with JavaScript to do the following. These can all be on one page.
  190. (a) Prompt the user for their name.
  191. (b) Use a pop-up box to welcome the user by name.
  192. (c) Display the current date on the page in the following format: April 30, 2018. Do not display the time. Do not "hard code" the date;
  193. (d) Display the last modified date of the document.
  194. (e) Put some useful advice, on any subject, in the status line of the browser.
  195. Solution:
  196. Code:
  197. <!DOCTYPE html>
  198. <html>
  199. <body>
  200. <p id="demo"></p>
  201. <script>
  202. window.status="hi users feel free to contact us";
  203. var person = prompt("Please enter your name");
  204. if (person != null) {
  205. document.getElementById("demo").innerHTML =
  206. alert("Hello " + person + "! How are you today?");
  207. }
  208. document.write("Current Date ")
  209. var d = new Date()
  210. var month=new array("jan","feb","mar","apr","may","june","jul","aug","sep","oct","nov","dec")
  211. document.write(month[d.getMonth()])
  212. document.write(" ")
  213. document.write(d.getDate())
  214. document.write(",")
  215. document.write(" ")
  216. document.write(d.getFullYear())
  217. var x = document.lastModified;
  218. document.getElementById("demo").innerHTML = "Last Modified " + x;
  219. window.status="heyy just updated status";
  220. </script>
  221. </body>
  222. </html>
  223.  
  224. 1. VIT University has organized campus recruitment from Google. After the interview only 10 students got placed in Google. Consider their register number for processing. Check whether a particular register number is in the placed list or not and display the same. Write a PHP program for the above scenario.
  225. CODE:
  226. <!DOCTYPE html>
  227. <html>
  228. <body>
  229. <?php
  230. $student = array("16BCE0001", "16BCE0002", "16BCE0003", "16BCE0004", "16BCE0005",
  231. "16BCE0006", "16BCE0007", "16BCE0008", "16BCE0009","16BCE0010");
  232. $length= count(student);
  233. $input = $_POST("register");
  234. for($x=0; $x<length; $x++)
  235. {
  236. if($input==$student[$x])
  237. {
  238. echo "You are shortlisted";
  239. } else
  240. {
  241. echo "You are not shortlisted";
  242. }
  243. } ?>
  244. <form action="hello.php" method="get">
  245. Register number: <input type="text" name="number" value="number">
  246. <input type="submit" value="submit">
  247. </form>
  248. </body>
  249. </html>
  250.  
  251. Create a PHP script that will output a form containing 2 fields: username and
  252. password. Upon submission of the form, the code should check against the database, to see whether the username and password pair was correct. If so, display a welcome message. If not, display the message “Invalid username or password” followed by the same login form.
  253.  
  254. Code:
  255. HTML:
  256. <html>
  257. <head>
  258. <title> Login Form</title>
  259. </head>
  260. <body>
  261. <form method="post" action="validate_login.php" >
  262. <table border="1" >
  263. <tr>
  264. <td><label for="user_id">userid</label></td>
  265. <td><input type="text"
  266. name="user_id" id="user_id"></td>
  267. </tr>
  268. <tr>
  269. <td><label for="users_pass">Password</label></td>
  270. <td><input name="users_pass"
  271. type="password" id="users_pass"></input></td>
  272. </tr>
  273. <tr>
  274. <td><input type="submit" value="Submit"/>
  275. <td><input type="reset" value="Reset"/>
  276. </tr>
  277. </table>
  278. </form>
  279. </body>
  280. </html>
  281.  
  282. PHP:
  283. <?php
  284. $servername = "localhost";
  285. $username = "scse";
  286. $password = "scse";
  287. $dbname = "login";
  288. $user_id = $_POST["user_id"];
  289. $pass = $_POST["users_pass"];
  290. $con = mysql_connect($servername, $username, $password, $dbname);
  291. if(! $con)
  292. {
  293. die('Connection Failed'.mysql_error());
  294. }
  295. mysql_select_db("login",$con);
  296. $result = mysql_query("SELECT user_id, users_pass FROM users WHERE user_id = $user_id");
  297. $row = mysql_fetch_array($result);
  298. if($row["user_id"]==$user_id && $row["users_pass"]==$pass)
  299. echo"welcome message";
  300. else
  301. echo"invalid username or password";
  302. ?>
  303.  
  304. Getting an appointment with Proctor Create a dashboard with following 3 tasks (3 different pages)
  305. Task a) Create a form for student which should ask the following details
  306. Regd. No (validation have to be tested us  ing JavaScript - regular expression)
  307.  Name of the student (validation – no digits must be there)
  308.  Reason to meet proctor (Text area Max limit = 100 words)
  309. <!DOCTYPE html>
  310. <html>
  311. <head>
  312. <title> Student meeting request </title>
  313. </head>
  314. <body>
  315. <h1>Student meeting form :</h1>
  316. <form action="studcheck.php" method="post"
  317. onsubmit="return validateForm()" >
  318. <label for="regno">Reg no:</label>
  319. <input type="text" name="regno" class="form-control" id="regno"
  320. pattern="[0-9]{2}[A-Za-z]{3}[0-9]{4}"> </br>
  321. <label for="name">name:</label>
  322. <input type="text" name="name" class="form-control" id="name"
  323. pattern="[A-Za-z ]*"> </br>
  324. <label for="Reason">Reason:</label>
  325. <input type="text" name="reason" class="form-control" id="reason">
  326. <button type="submit" class="btn btn-default"
  327. name="subd">Submit</button> </br>
  328. </form>
  329. <script>
  330. function validateForm() {
  331. var x=document.getElementById("name");
  332. var y=document.getElementById("regno");
  333. if (x.value.match("\^[0-9]{2}[A-Za-z]{3}[0-9]{4}\")) {
  334. alert("not valid");
  335. return false;
  336. }
  337. if (y.value.match("\^[A-Za-z ]*\")) {
  338. alert("not valid");
  339. return false;
  340. }
  341. }
  342. </script>
  343. </body>
  344. </html>
  345. Task b) Create a login with the user name faculty and allow the faculty to use the password “technology@123” to login to the system. After successful login to the system, the proctor must
  346.  be able to see all the requests
  347.  The proctor can mention the particular time for each student
  348. <html>
  349. <head>
  350. <h3>Proctor login form</h3>
  351. </head>
  352. <body>
  353. <form action="studcheck.php" method="post" onsubmit="return validateForm()">
  354. Username <input type="text" name="username" value="username" ></br>
  355. Password <input type="password" name="password" value="password"></br>
  356. <input type = "submit" name="submit" value="submit">
  357. </form>
  358. <script>
  359. function validateForm() {
  360. var x=document.getElementById("username");
  361. var y=document.getElementById("password");
  362. if ((x != ("faculty")) || (y != ("technology@123"))) {
  363. alert("not valid");
  364. return false;
  365. }
  366. }
  367. </script>
  368. </body>
  369. </html>
  370.  
  371. Task c)When the appointment is fixed by the proctor, all the appointments should be visible in this page (only Registration number of the student and time should be visible to everyone)
  372. <?php
  373. $servername = "localhost";
  374. $username = "scse";
  375. $password = "scse";
  376. $conn = mysqli_connect($servername, $username, $password, "scse");
  377. $name = $regno = $reason = "";
  378. $sql = "INSERT INTO proctor (reg_no, name, reason) VALUES ('16BCB0054', 'Khushi', 'lEAVE RELATED')";
  379. if(isset($_POST["subd"])){
  380. $name = $_POST["name"];
  381. $regno = $_POST["regno"];
  382. $reason = $_POST["reason"];
  383. $sql = "INSERT INTO proctor (regno, name, reason) VALUES ( '$regno','$name', '$reason')";
  384. mysqli_query($conn,$sql);}
  385. ?>
Add Comment
Please, Sign In to add comment