Thursday, 21 December 2017

AWT-Slip29

1)Write a script to create XML file named “Course.xml”
<Course>
<Computer Science>
<Student name>.......</Student name>
<Class name>......</Class name>
<percentage>.....</percentage>
</Computer Science>
</Course>
Store the details of 5 students who are in TYBCA.                                                                                      
Course.xml

<?xml version="1.0" ?>
<?xml-stylesheet type="text/css" href="course.css"?>
  
<course>
<Computer_Science>
<Student_name>Sachin pawar</Student_name>
<Class_name>SYBCS</Class_name>
<percentage>56</percentage>
</Computer_Science>

<Computer_Science>
<Student_name>Sima pawar</Student_name>
<Class_name>FYBCS</Class_name>
<percentage>78</percentage>
</Computer_Science>
</course>       

course.css

course
{
            font-size: 30pt;
            font-weight:Bold;
            color:red;
           
}    


2)Write a PHPscript using AJAX concept, to check user name and password are valid or Invalid(use database to store user name and password).


slip29.html
<html>
<head>
<script type="text/javascript">
function validate()
{
uname=document.getElementById('uname').value;
pwd=document.getElementById('pwd').value;
}
</script>
</head>
<body>
<form action="slip29.php" method=get>
Enter UserName<input type=text name=uname id=uname><span id=a></span><br>
Enter Password<input type=password name=pwd id=pwd><br>
<input type=SUBMIT value=SUBMIT onClick=validate()>
</form>

</body>
</html>


slip29.php

<?php
$database="archana";
$uname=$_GET['uname'];
$password=$_GET['pwd'];

$con=mysql_connect("localhost","root","") or die("I cannot connect");
$d=mysql_select_db("archana",$con);
$q=mysql_query("select * from users");

$n=0;
while($row=mysql_fetch_array($q))
{
if($row[0]==$uname && $row[1]==$password)
$n=1;
}

if($n==0)
echo "invalid username or password";

else
echo "valid username or password";  
?>