This document was uploaded by user and they confirmed that they have the permission to share
it. If you are author or own the copyright of this book, please report to us by using this DMCA
report form. Report DMCA
Overview
Download & View Questions Answers as PDF for free.
// cancel close timer mcancelclosetime(); // close old layer if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; // get new layer and show it ddmenuitem = document.getElementById(id); ddmenuitem.style.visibility = 'visible'; } // close showed layer function mclose() { if(ddmenuitem) ddmenuitem.style.visibility = 'hidden'; } // go close timer function mclosetime() { closetimer = window.setTimeout(mclose, timeout); } // cancel close timer function mcancelclosetime() { if(closetimer) { window.clearTimeout(closetimer); closetimer = null; } } // close layer when click-out document.onclick = mclose; //-->
Q 5. Create Html page with following requirements. 1) Create form with validations & following fields... I . Your Name: ---- not blank II. Your Gender:(Male / Female) use radio buttons ---- one must be choose III. Your Age: ( listbox ) ---- one must be select IV. Email Address : ---- not blank, email validations Ans:- Create new page “ formvalidation.html” & put following code. A More Complex Form with JavaScript Validation <script type="text/javascript">
General Document (GENT002-V.1.0)
IT Shastra (I) Pvt. Ltd.
{ alert ( "Please fill in the 'Your Name' box." ); return false; } if ( ( document.contact_form.gender[0].checked == false ) && ( document.contact_form.gender[1].checked == false ) ) { alert ( "Please choose your Gender: Male or Female" ); return false; } if ( document.contact_form.age.selectedIndex == 0 ) { alert ( "Please select your Age." ); return false; } if (document.contact_form.email.value == "") { alert ("Please Enter Email"); //document.contact_form.email.focus(); return false; } var emailVal = document.contact_form.email.value; if ( emailVal == "" || emailVal.indexOf("@") <= 0 || emailVal.indexOf(".") <= 0 ) { alert("Please supply a valid email address"); // document.form1.email.focus(); return false; } return true; } //-->
Q 6. Write program for open popup window using onClick event. Ans:- Create new page “ popup.html” & put following code. <script type="text/javascript">
if (document.f1.email.value == "") { alert ("Please Enter Email"); document.f1.email.focus(); return false; } var emailVal = document.f1.email.value; if ( emailVal == "" || emailVal.indexOf("@") <= 0 || emailVal.indexOf(".") <= 0 ) { alert("Please supply a valid email address"); document.f1.email.focus(); return false; } return true; }
4) Create new page config.php, put following code.
General Document (GENT002-V.1.0)
IT Shastra (I) Pvt. Ltd.
{ while(list($name,$value) = each($HTTP_GET_VARS)) { $$name = $value; }; }; // Get the names and values for post vars if (isset($HTTP_POST_VARS)) { while(list($name,$value) = each($HTTP_POST_VARS)) { $$name = $value; }; }; ?>
5) Create new page view_info.php & put following code in page. <TITLE> New Document <META NAME="Generator" CONTENT="EditPlus"> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT="">
General Document (GENT002-V.1.0)
if (isNaN(document.f1.rollno.value)) { alert ("Please Enter Valid Roll Number"); document.f1.rollno.focus(); return false; } if (isNaN(document.f1.phone.value)) { alert ("Please Enter Valid Phone Number"); document.f1.phone.focus(); return false; } if (document.f1.email.value == "") { alert ("Please Enter Email"); document.f1.email.focus(); return false; } var emailVal = document.f1.email.value; if ( emailVal == "" || emailVal.indexOf("@") <= 0 || emailVal.indexOf(".") <= 0 ) { alert("Please supply a valid email address"); document.f1.email.focus(); return false; } return true; }
8) Create new file delete.php & put following code..
Q 8. Create Login - Logout with a Session in 1 file. require 2 PHP files and 1 table of mySQL database. 1.index.php this file is the Login and Logout file. 2.main.php this file is the target when login is O.K. 3.Database "tutorial" and table "admin" with 3 fields: id(auto_increment), username(varchar, 50), password(varchar,
Ans:- 1) Create new file index.php & put following code.. // Use session variable on this page. This function must put on the top of page. session_start(); ////// Logout Section. Delete all session variable. session_destroy(); $message=""; ////// Login Section. $Login=$_POST['Login']; if($Login){ // If clicked on Login button. $username=$_POST['username']; $password=$_POST['password']; // Encrypt password with md5() function. // Connect database. $host="localhost"; // Host name. $db_user="root"; // MySQL username. $db_password=""; // MySQL password. $database="phpcourse"; // Database name. mysql_connect($host,$db_user,$db_password); mysql_select_db($database); // Check matching of username and password. $result=mysql_query("select * from login where user='$username' and pass='$password'"); if(mysql_num_rows($result)!='0'){ // If match. session_register("username"); // Craete session username. header("location:main.php"); // Re-direct to main.php exit; }else{ // If not match. $message="--- Incorrect Username or Password ---"; } } // End Login authorize check. ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Home echo $message; ?> 2) Create new file main.php & put following code.. // You may copy this PHP section to the top of file which needs to access after login. session_start(); // Use session variable on this page. This function must put on the top of page. if(!session_is_registered("username")){ // if session variable "username" does not exist. header("location:index.php"); // Re-direct to index.php } ?> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Untitled Document
Hello echo $_SESSION['username']; ?>! You are now Logged in.