-
retrieve the data from sql to textbox
i got 2 html pages with the following data
index.php (buttons: SAVE, EDIT)
update.php (buttons: UPDATE,DELETE)
Employee ID (primary key),
Employee Name (here i putting 2 buttons Edit,Save)
when i entered the empid and click the Edit button, the page has to go from index.php to update.php and at the same time it has to display the employee name w.r.t the empID
and i've written the code for update and delete buttons in update.php
my problem is i am not able to fill the textboxes in update.php w.r.t empid
and at the same time can't navigate to the update.php
please help me in this regard
THIS IS MY INDEX.PHP
<html>
<head>
<title>Sample PHP APP</title>
<script language="javascript">
function onsave()
{
document.home.action="index.php";
document.home.submit();
}
function onedit()
{
document.home.action="index1.php";
document.home.submit();
}
</script>
</head>
<body>
<form name="home" method="post">
<table class="tbl" align="center" cellpadding="2" cellspacing="15px" >
<tr>
<td align="right">Associate ID* <input type="text" name="Aidtxt"></td>
<td>
<td>
Associate Name* <input align="right" type="text" name="Anametxt">
</td>
<tr>
<td align="right"><input type="submit" value="Save" name="savbtn" onclick="return onsave();"></td>
<td align="left"><input type="submit" value="Edit" name="edtbtn" onclick=" return onedit();">
</tr>
</table>
</form>
</body>
</html>
<?php
include("conf/conf.php");
$dbConf = new aphpConf();
$databaseURL = $dbConf->get_databaseURL();
$databaseUName = $dbConf->get_databaseUName();
$databasePWord = $dbConf->get_databasePWord();
$databaseName = $dbConf->get_databaseName();
$connection = mysql_connect($databaseURL,$databaseUName,$databasePWord);
// or die ("Error while connecting to localhost");
$db = mysql_select_db($databaseName,$connection);
//or die ("Error while connecting to database");
$insert = "INSERT INTO Employeeinfo (AID,ANAME,DESG,FNAME,DoJ,MBNUM,EMAIL)
Values ('$_POST[Aidtxt]','$_POST[Anametxt]','$_POST[Desigtxt]','$_POST[Fnametxt]',
'$_POST[DoJtxt]','$_POST[Mbnumtxt]','$_POST[Emailtxt]')";
if (!mysql_query($insert,$connection))
{
die ('Error: '.mysql_error());
}
echo "1 record added";
mysql_close($connection)
?>
AND THIS IS UPDATE.PHP
<html>
<head> </head>
<body>
<form action="update.php" method="post">
<table class="tbl" align="center" cellpadding="2" cellspacing="15px" >
<tr>
<td align="right">
Associate ID <input type="text" name="Aidtxt" value="<?PHP echo $_POST["Aidtxt"]; ?>"> </td>
<td align="right">
Associate Name <input type="text" name="Anametxt" > </td>
</tr>
<tr>
<td align="right"><input type=submit value="Update" name="Updatetxt"></td>
<td align="left"><button value="Cancel" onclick="location='http://172.16.5.56/appphp/index.php';">Cancel</button></td>
</tr>
</table>
</form>
</body>
</html>
<?php
include("conf/conf.php");
$dbConf = new aphpConf();
$databaseURL = $dbConf->get_databaseURL();
$databaseUName = $dbConf->get_databaseUName();
$databasePWord = $dbConf->get_databasePWord();
$databaseName = $dbConf->get_databaseName();
$connection = mysql_connect($databaseURL,$databaseUName,$databasePWord);
// or die ("Error while connecting to localhost");
$db = mysql_select_db($databaseName,$connection);
//or die ("Error while connecting to database");
mysql_query("UPDATE Employeeinfo SET ANAME='$_POST[Anametxt]',DESG='$_POST[Desigtxt]',FNAME='$_POST[Fnametxt]',DoJ='$_POST[DoJtxt]',
MBNUM='$_POST[Mbnumtxt]',EMAIL='$_POST[Emailtxt]' WHERE AID='$_POST[Aidtxt]'");
mysql_close($connection);
?>
I had seperate configuration file from where i can retrieve the database information and also
The first problem is
when i enter the associate/Employee id in index.php, w.r.t to that id , the data has to be retrieved from database to update.php.
and the second one is
i want to display a warn message box if the employee id entered by user in index.php is not there in database
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks