here in my page "eg3.php" ..."NEW" and "Delete" button are working fine ... but when i click "edit" button ... the "update.php" page opens but with empty textboxes as if i have to insert NEW data ... that is the problem... the text boxes should display data of checked row of "eg3.php" .

I m giving both eg3.php as well as update.php and the updatedata.php files....plzzzzzzzz do help me :( :( as soon as possible.Thnx in advance and will gv later 2 :( .

eg3.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
	background-color: #87AEC5;
}
-->
</style>



<script language="javascript">

function second(){
        document.form1.action="update.php";
}
</script></head>
<body>
<?php
include("config.php");

$sql="SELECT * FROM contact";
$result=mysql_query($sql);?>
<table align="center" width="700" border="0"><tr><td><?php
echo "<form name='form1' method=post action=''>"; 
echo "<table border='0' cellspacing='0' cellpadding='2' width='600' align='center'>"; 
echo"<tr bgcolor='#ffffff'>";
echo"<td>&nbsp;</td>";
echo"<td align='center' bgcolor='#FFFFFF'><strong>emailid</strong></td>";
echo"<td align='center' bgcolor='#FFFFFF'><strong>forwarding</strong></td>";
echo"<td align='center' bgcolor='#FFFFFF'><strong>autoresponse</strong></td>";
echo"<td align='center' bgcolor='#FFFFFF'><strong>company</strong></td>";
echo"<td align='center' bgcolor='#FFFFFF'><strong>Password</strong></td>";
echo"<td align='center' bgcolor='#FFFFFF'>&nbsp;</td></tr>";
while($rows=mysql_fetch_array($result)){

echo"<tr bgcolor='#ffffff'>";
echo"<td>";
echo"<input type = 'checkbox' name='box[]' value=\"".$rows['emailid']."\"'</td>";
echo"<td align='center' bgcolor='#FFFFFF'>".$rows['emailid']."</td>";
echo"<td align='center' bgcolor='#FFFFFF'>".$rows['forwarding']."</td>";
echo"<td align='center' bgcolor='#FFFFFF'>".$rows['autoresponse']."</td>";
echo"<td align='center' bgcolor='#FFFFFF'>".$rows['company']."</td>";
echo"<td align='center' bgcolor='#FFFFFF'>".$rows['password']."</td>";
echo"<td align='center' bgcolor='#FFFFFF'>&nbsp;</td></tr>";
}

?>
  <tr>
    <td colspan =6 align=center>&nbsp;</td>
  </tr>
  <tr><td colspan =6 align=center><input type="button" name="new" value="New" onClick="window.location.href='second.php'" />
  <input type="submit" name="edit" value="To Edit" onClick="second()">
    <input type="submit" value="Delete" name="delete">
    <label></label>
</td>
</tr></table>
</form></td></tr></table>

<?php
if(isset($_POST['delete'])){//check to see if the delete button has been pressed

   if(isset($_POST['box'])){ //check to see if any boxes have been checked 
        $num = 0;//used to count the number of rows that were deleted
        $box = $_POST['box'];
        while (list ($key,$val) = @each ($box)) { //loop through all the checkboxes
              $num++;
              $sqldel="DELETE FROM contact WHERE emailid='$val'";//delete any that match id
              $resdel=mysql_query($sqldel);//send the query to mysql
        }
        //print the logs that were deleted
       echo"$num record(s) have been deleted.";
	   echo "<meta http-equiv=\"refresh\" content=\"0;URL=eg3.php\">";
	   //<META HTTP-EQUIV=Refresh CONTENT="3; URL=eg2.php">
   }
   else{//no boxes checked
   echo "No records selected.";
   }
}
?>
<?php
if(isset($_POST['edit'])){//check to see if the edit button has been pressed
echo "yess";
   if(isset($_POST['box'])){ //check to see if any boxes have been checked 
        $num = 0;//used to count the number of rows that were deleted
        $box = $_POST['box'];
        while (list ($key,$val) = @each ($box)) { //loop through all the checkboxes
              $num++;
			  
			  $emailid='$val';
              
			  
			 
        }
        
   }
  			else{//no boxes checked
   			echo "No records selected.";
   				}
}
?>


</center>


</body> 
</html>

update.php

<html>
<head>
<title>Email Control</title>
<link href="email-styles.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>
<?php 
include("config.php"); 

$emailid=$_GET['emailid'];
echo "$emailid";
	$forwarding=$_REQUEST['forwarding'];
	$autoresponse=$_REQUEST['autoresponse'];
	$password=$_REQUEST['password'];
	$company=$_REQUEST['company'];?>
	<?php
//$id=$_REQUEST['email'];
//Retrieve data from database 
echo "$emailid";
$sql="SELECT * FROM contact where emailid='$emailid'";
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);

?>

<table width="600" align="center">
<tr>
<td>
<form  name="edit_email" action="updatequery.php" method="post">
<table width="600" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td class="emailtext">Company</td>
    <td ><label>
      <input type="text" name="company" id="company" value="<? echo $rows['company']; ?>">
    </label></td>
  </tr>
  <tr>
    <td class="emailtext">Email Id</td>
    <td ><input type="text" name="emailid" id="emailid" value="<?php echo "$id"; ?>" readonly="readonly" /></td>
  </tr>
  <tr>
    <td class="emailtext">Password</td>
    <td><label for="password"></label>
      <input type="password" name="password" id="password" value="<? echo $rows['password']; ?>"></td>
  </tr>
  <tr>
    <td class="emailtext">Re-Type Password</td>
    <td><label for="repassword"></label>
      <input type="password" name="repassword" id="repassword" value="<? echo $rows['password']; ?>"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF" class="emailtext">Forwarding Mails</td>
    <td bgcolor="#FFFFFF"><label>
      <input name="radiobutton" type="radio" value="radiobutton">
      Yes</label>      
      
      <label>
      <input name="radiobutton" type="radio" value="radiobutton">
      No</label>
      <label for="cb1"><br>
  </label>
  <label for="forwarding"></label>
      <span class="emailtext">To</span>
      <input type="text" name="forwarding" id="forwarding" value="<? echo $rows['forwarding']; ?>"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF" class="emailtext">Auto Response
      <label for="response"></label></td>
    <td bgcolor="#FFFFFF"><label>
      <input name="radiobutton" type="radio" value="radiobutton">
      Yes</label>
      
      <label>
      <input name="radiobutton" type="radio" value="radiobutton">
      No</label>
      <label for="cb2"><br>
      </label>      <textarea name="response" id="response" cols="45" rows="5" value="<? echo $rows['autoresponse']; ?>"><? echo $rows['autoresponse']; ?></textarea></td>
  </tr>
  <tr>
    <td colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" id="submit" value="Update">
      <label>
      <input type="button" name="back" value="Back" onClick="window.location.href='eg3.php'">
      </label></td>
    </tr>
</table>
</form>
</td></tr>
</table>

updatedata.php

<?php 
include("config.php"); 
?>
<?php
$id=$_REQUEST['emailid'];
echo "email id :$id";
$forwarding=$_REQUEST['forwarding'];
echo "forwarding to: $forwarding";
$autoresponse=$_REQUEST['response'];
echo "With auto response : $autoresponse is inserted";
$company=$_REQUEST['company'];
echo "$company"; 
$password=$_REQUEST['repassword'];
echo "$password"; ?>
<?php

if ($company == "kesom") {
    $uid=1;
} elseif ($company == "ops") {
    $uid=2;
} elseif ($company == "bucati") {
    $uid=3;
}
?>
<?php
// update data in mysql database 
$sql="UPDATE contact SET uid='$uid',emailid='$id', forwarding='$forwarding', autoresponse='$autoresponse', company='$company',password='$password' WHERE emailid='$id'";
$result=mysql_query($sql);

// if successfully updated. 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='eg3.php'>Back to main page</a>";}

else {
echo "ERROR";
}

?>

The Main main main problem is i have to pass "emailid" value to the update.php page !!!

Can you please point me to where you think there is problem. what line or share more idea???

Just cant read through all your code now but i will be online for the 2 hours.

waiting for your reply :)

richieking


TanQ so much ... but dat UPDATE link in the first page has solved the problem (the thread u saw me jst a while be4 ) :) :)

now if u can help .. :| .. help me in radio buttons ... i want 'forwarding' text enable only if user chooses 'yes' radio button...same in auto response.

<html>
<head>
<title>Email Control</title>
<link href="email-styles.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

</head>
<body>
<?php 
include("config.php"); 
?>
<table width="600" align="center">
<tr>
<td>
<form  name="edit_email" action="savedata.php" method="post">
<table width="600" border="0" cellpadding="0" cellspacing="5">
  <tr>
    <td class="emailtext">Company</td>
    <td ><label>
      <input type="text" name="company" id="company">
    </label></td>
  </tr>
  <tr>
    <td class="emailtext">Email Id</td>
    <td ><label for="emailid"></label>
      <input type="text" name="emailid" id="emailid"></td>
  </tr>
  <tr>
    <td class="emailtext">Password</td>
    <td><label for="password"></label>
      <input type="password" name="password" id="password"></td>
  </tr>
  <tr>
    <td class="emailtext" onblur="checkpass(this)">Re-Type Password</td>
    <td><label for="repassword"></label>
      <input type="password" name="repassword" id="repassword"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF" class="emailtext">Forwarding Mails</td>
    <td bgcolor="#FFFFFF"><label>
      <input name="radiobutton" type="radio" value="yes">
      Yes</label>      
      
      <label>
<input name="radiobutton" type="radio" value="no"> 
No</label>
      <label for="cb1"><br>
  </label>
  <label for="forwarding"></label>
      <span class="emailtext">To</span>
      <input type="text" name="forwarding" id="forwarding"></td>
  </tr>
  <tr>
    <td valign="top" bgcolor="#FFFFFF" class="emailtext">Auto Response
      <label for="response"></label></td>
    <td bgcolor="#FFFFFF"><label>
      <input name="radiobutton" type="radio" value="radiobutton">
      Yes</label>
      
      <label>
      <input name="radiobutton" type="radio" value="radiobutton">
      No</label>
      <label for="cb2"><br>
      </label>      <textarea name="response" id="response" cols="45" rows="5" ></textarea></td>
  </tr>
  <tr>
    <td colspan="2" align="center" bgcolor="#FFFFFF"><input type="submit" name="submit" id="submit" value="SAVE">
      <label>
      <input type="button" name="back" value="Back" onClick="window.location.href='index.php'">
      </label></td>
    </tr>
</table>
</form>
</td></tr>
</table>

Te radio button value does not contain any reasonable value on line 54-61.

And how are you passing the variable over to the next file ...???

please more info :)

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.