pagelisting.php.............

<html>
<head>
<h3 style="text-align:center;background-color:yellow">THIS THE LISTING PAGE</h3>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<?php

include("home.php");
?>
</head>
<body>
    <form action="" method="post" name="form1">
    <br/><br/>
    <a href="fillup.php"><tr><th>Contacts</th></tr></a>
    <br/><br/>
    <input type="text" name="searchtext"/>
    <input type="submit" name="submit" Value="Search"/>

</body>
</html>
<?php
include("database.php");
$var=$_POST['searchtext'];
if(isset($_POST['submit']))
{
$sql="SELECT * FROM information WHERE fname LIKE '{$var}%'";
$q=mysql_query($sql) or die("some errror".mysql_error());
echo "<table border='1'>
  <tr>
  <th>SNO</th>
  <th>FirstName</th>
  <th>LastName</th>
  <th>Address</th>
  <th>Phone NO</th>
  </tr>";
  while ($row = mysql_fetch_array($q)) {
  echo "<tr>";
  echo "<td>" . $row[sno] . "</td>";
  echo "<td>" . $row[fname] . "</td>";
  echo "<td>" . $row[lname] . "</td>";
  echo "<td>" . $row[addr] . "</td>";
  echo "<td>" . $row[phone] . "</td>";
  echo ("<td>"."<a href=\"update.php\?slno=$row[sno]\">UPDATE</a>"."</td>");
  echo "</tr>";

  }
  echo "</table>";

  //mysql_close($con);
}
/*if($_GET['status']=='pagelisting')
{
echo "this is main page";
}*/
?>




update.php.....................

<?php
include("database.php");

//$a=$_GET['slno'];
$sql="SELECT * FROM information WHERE sno='{$slno}'";
$q=mysql_query($sql);

while($row=mysql_fetch_array($q)){

$sno=$row['sno'];
$fname=$row['fname'];
$lname=$row['lname'];
$addr=$row['addr'];
$phone=$row['phone'];
}

mysql_free_result($q);
?>

<html>
<head><h2>edit the data...</h2></head>

<body>
<form action="update_data.php" method="post">
SNO:<br/>
<input type="text" value="<?php echo $sno; ?>" name="serno" disabled />
<br/>
FirstName:<br/>
<input type="text" value="<?php echo $fname; ?>" name="fstname"  />
<br/>
LastName:<br/>
<input type="text" value="<?php echo $lname; ?>" name="lstname"  />
<br/>
Address:<br/>
<input type="text" value="<?php echo $addr; ?>" name="adrs"  />
<br/>
Phone No:<br/>
<input type="text" value="<?php echo $phone; ?>" name="phon"  />
<br/>
<input type="submit" value="submit changes" />
</form>
</body>
</html>



update_data.php...........................

<?php

include ("database.php");
//include("home.php");
$sno=$_POST['serno']
$fn=$_POST['fstname'];
$ln=$P_OST['lstname'];
$adr=$POST['adrs'];
$pn=$POST['phon'];

$sql="UPDATE information SET fname='$fn',lname='$ln',addr='$adr',phone='$pn' WHERE sno='$sno'";
mysql_query($sql) or die("Error: "mysql_error());

echo "successful.<a href=\"pagelisting.php\"> Return </a>" ;
?>

This is my update.php code file...... here 'slno' ** is coming from another file named **pagelisting.php.Now when I click the submit button of "update.php file " after putting new data it is not goiing to the destination file named "update_data.php". Guys please help me...??

Recommended Answers

All 2 Replies

It does not know what 'slno' is.. store inside a session :)

commented: can please show me how?? +0

<form action="update_data.php" method="post">
SNO:<br/>
<input type="text" value="<?php echo $sno; ?>" name="serno" disabled />
<br/>

i just want to ask why you have the word "disabled" in this code????

commented: because u can't edit this one +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.