-
-
Save shrishailbelanke/2204542 to your computer and use it in GitHub Desktop.
web based application using php(ajax) CCPP ID 933
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using this project User Can insert employee information and fetch employee data from database. | |
| 1. system must have Wamp server installed on it. | |
| 2. Copy given folder into "C:\wamp\www". | |
| 3. create a database and table using following commands. | |
| mysql>create database shree; | |
| mysql>create table emp(eid int,ename varchar(20),Age int,city varchar(20),Designation varchar(20)); | |
| mysql> insert into emp values(1011,'shrishail',22,'kolhapur','Manager'); | |
| mysql> insert into emp values(1012,'Sanjay',23,'Pune','SalesManager'); | |
| mysql>insert into emp values(1013,'Sunil',26,'Mumbai','Programmer'); | |
| mysql>insert into emp values(1014,'Santosh',30,'Delhi','Manager'); | |
| 4. Finally Run this project through wamp server. | |
| regards, | |
| Shrishail Belanke | |
| shrishailbelanke@gmail.com | |
| 9764878788 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var xmlHttp; | |
| function sendEmpID(str) | |
| { | |
| xmlHttp=GetXmlHttpObject(); | |
| if (xmlHttp==null) | |
| { | |
| alert ("Browser does not support HTTP Request") | |
| return; | |
| } | |
| var url="getemp.php"; | |
| url=url+"?q="+str; | |
| url=url+"&sid="+Math.random(); | |
| xmlHttp.onreadystatechange=stateChanged; | |
| xmlHttp.open("GET",url,true); | |
| xmlHttp.send(null); | |
| } | |
| function stateChanged() | |
| { | |
| if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") | |
| { | |
| document.getElementById("emp").innerHTML=xmlHttp.responseText; | |
| } | |
| } | |
| function GetXmlHttpObject() | |
| { | |
| var xmlHttp=null; | |
| try | |
| { | |
| xmlHttp=new XMLHttpRequest(); | |
| } | |
| catch (e) | |
| { | |
| try | |
| { | |
| xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); | |
| } | |
| catch (e) | |
| { | |
| xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); | |
| } | |
| } | |
| return xmlHttp; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script src="ajax.js"></script> | |
| </head> | |
| <body><form> | |
| <?php | |
| echo "Welcome ".$_GET["uname"]; | |
| echo "<br><a href=insert.html>Insert Employee information</a>"; | |
| echo "<br>Select Employee information by ID:"; | |
| echo "<select name=nm onchange=sendEmpID(this.value)>"; | |
| echo "<option>select ID</option>"; | |
| $con = mysql_connect("localhost","root","root"); | |
| if($con) | |
| { | |
| echo "Success"; | |
| if(mysql_select_db("shree",$con)) | |
| { | |
| $sql="select eid from emp"; | |
| $result=mysql_query($sql,$con); | |
| while($row = mysql_fetch_array($result)) | |
| { | |
| echo"<option value=".$row['eid'].">".$row['eid']."</option>"; | |
| } | |
| } | |
| else | |
| { | |
| echo "Error : ".mysql_error(); | |
| } | |
| } | |
| else | |
| { | |
| echo "Connection Failed".mysql_error(); | |
| } | |
| echo"</select>"; | |
| ?> | |
| </form><p> | |
| <div id="emp"></div></p> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $q=$_GET["q"]; | |
| $con = mysql_connect('localhost', 'root', 'root'); | |
| if (!$con) | |
| { | |
| die('Not able to connect: ' . mysql_error()); | |
| } | |
| mysql_select_db("shree", $con); | |
| $query="SELECT * FROM emp WHERE eid = '".$q."'"; | |
| $result = mysql_query($query); | |
| echo "<table border='1'> | |
| <tr> | |
| <th>Name</th> | |
| <th>Age</th> | |
| <th>City</th> | |
| <th>Designation</th> | |
| </tr>"; | |
| while($row = mysql_fetch_array($result)) | |
| { | |
| echo "<tr>"; | |
| echo "<td>" . $row['ename'] . "</td>"; | |
| echo "<td>" . $row['Age'] . "</td>"; | |
| echo "<td>" . $row['city'] . "</td>"; | |
| echo "<td>" . $row['Designation'] . "</td>"; | |
| echo "</tr>"; | |
| } | |
| echo "</table>"; | |
| mysql_close($con); | |
| ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <?php | |
| $con=mysql_connect("localhost","root","root"); | |
| if($con) | |
| { | |
| if(mysql_select_db("shree",$con)) | |
| { | |
| $sql="insert into emp (eid,ename,Age,city,Designation) values (".$_REQUEST["eid"].",'" | |
| .$_REQUEST["ename"]."',".$_REQUEST["age"].",'".$_REQUEST["city"]."','".$_REQUEST["dg"]."');"; | |
| echo $sql; | |
| mysql_query($sql,$con); | |
| } | |
| } | |
| else | |
| { | |
| echo "Failed".mysql_error(); | |
| } | |
| ?> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <body> | |
| <form action="insertdb.php" method="post"> | |
| <table border=1 bgcolor="skyblue"> | |
| <tr><td>Enter Employee Id</td><td> | |
| <input type="text" name="eid"></td></tr> | |
| <tr><td>Enter Employee Name</td> | |
| <td><input type="text" name="ename"></td></tr> | |
| <tr><td>Enter Employee Age</td><td> | |
| <input type="text" name="age"></td></tr> | |
| <tr><td>Enter Employee City</td><td> | |
| <input type="text" name="city"></td></tr> | |
| <tr><td>Enter Employee Designation </td> | |
| <td><input type="text" name="dg"></td></tr> | |
| <tr><td colspan=2 align="center"> | |
| <input type="submit" value="Insert into Database"></td></tr> | |
| </table> | |
| </form> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <script type="text/javascript"> | |
| function validate(theForm) | |
| { | |
| if(theForm.uname.value.length==0) | |
| { | |
| alert("User name can't be blank"); | |
| theForm.uname.focus(); | |
| return false; | |
| } | |
| else if(theForm.pwd.value.length==0) | |
| { | |
| alert("Password can't be blank"); | |
| theForm.pwd.focus(); | |
| return false; | |
| } | |
| else if(theForm.pwd.value.length<6) | |
| { | |
| alert("Password length can't be less than 6 char"); | |
| theForm.pwd.focus(); | |
| return false; | |
| } | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <form action="display.php" onSubmit="return validate(this)"> | |
| <table align="center" border=2 cellspacing=2 cellpading=2> | |
| <tr><td>Enter your name</td> | |
| <td><Input type="text" name="uname"/></td></tr> | |
| <tr><td>Enter your password</td> | |
| <td><input type="password" name="pwd"/></td></tr> | |
| <tr><td><input type="submit" value="Submit"/></td> | |
| <td><input type="reset" value="Clear"/></td></tr></table> | |
| </form> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment