Ajax Based Program in PHP Programming, Study notes of Computer Programming

PHP Ajax Based Program for BCA and Bsc(Computer Science ) Student.

Typology: Study notes

2022/2023

Available from 07/25/2023

sonia-baviskar
sonia-baviskar 🇮🇳

3 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Write a PHP script using AJAX concept, to check user name and password are valid or Invalid (use database to store user name
and password). (29)
Html file :
<html>
<head>
<script type="text/javascript">
function validate()
{
uname=document.getElementById('uname').value;
pwd=document.getElementById('pwd').value;
}
</script>
</head>
<body>
<form action="slip_29-1.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>
Php file :
<?php
$uname=$_GET['uname'];
$password=$_GET['pwd'];
$con=mysql_connect("localhost","root","") or die("I cannot connect");
$d=mysql_select_db("slip29",$con);
$q=mysql_query("select * from login");
$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";
?>
Html file :
<html>
<head>
<script type="text/javascript">
function Addition()
{
var ob=false;
ob=new XMLHttpRequest();
var no1=document.getElementById("no1").value;
var no2=document.getElementById("no2").value;
ob.open("GET","Que25.php?num1="+no1+"&num2="+no2);
ob.send();
ob.onreadystatechange=function()
{
if(ob.readyState==4 && ob.status==200)
document.getElementById("add").innerHTML=ob.responseText; }
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Ajax Based Program in PHP Programming and more Study notes Computer Programming in PDF only on Docsity!

  1. Write a PHP script using AJAX concept, to check user name and password are valid or Invalid (use database to store user name and password). (29)

Html file :

Enter UserName Enter Password

Php file :

Html file :

Enter first no : Enter second no :

Php File :

  1. Write an Ajax program to display list of games stored in an array on clicking OK button. [15] (27) Html file :

Display the list of Games

$add=$n1+$n2; echo "Addition = ".$add; } else "enter both nos"; ?>

  1. Write Ajax program to get book details from XML file when user select a book name. Create XML file for storing details of book (title, author, year, price) [25] (16)

Search

suggestions :

Php file :

{ $match=""; for($i=0;$i

  1. Write Ajax program to print Movie details by selecting an Actor’s name. Create table MOVIE and ACTOR as follows with 1 : M cardinality MOVIE (mno, mname, release_yr) and ACTOR(ano, aname) 25 Html file :

Select Actor Name :

Php file : "; echo "Movie NoMovie NameRelease Year";

while($row = mysql_fetch_array($q)) { echo ""; echo "".$row[0].""; echo "".$row[1].""; echo "".$row[2].""; echo ""; }

echo ""; ?>

  1. Write a PHP script using AJAX concept, to develop user-friendly and interactive search engine (like a Google search engine) (13)

HTML File

Slip13.html

req=new ActiveXObject("Microsoft.XMLHttp"); } functionfetchdata(datasource,divID) { if(req) { req.open("GET",datasource); req.onreadystatechange=function() { if(req.readyState==4 &&req.status==200) { document.getElementById(divID).innerHTML=req.responseText; } } req.send(null); } }

data will be here

myfile.txt Ajax stands for asyncronousjavascript and xml

  1. Write Ajax program to carry out validation for a username entered in textbox. If the textbox is blank, print ‘Enter username’. If the number of characters is less than three, print’ Username is too short’. If value entered is appropriate the print ‘Valid username’. [25] (8)

Html file :

Enter Username :

  1. Create employee table as follows emp(eno, ename, designation ). Write Ajax program to select the emp name and print the selected employee details. 25

html file :

Select Name Of Employee :

php file :

"; echo "EnoEnameDesignationsalary";

while($row=mysql_fetch_array($q)) { echo ""; echo "".$row[0].""; echo "".$row[1].""; echo "".$row[2].""; echo "".$row[3].""; echo ""; }