how to disable the form

hi…its me again…ok let me explain…
1stpage:userlogin-user login using their ID and password.
2ndpage-fill in page-in this page all the particular about user will display.How i do it…I select from database use $_SESSION[‘ID’] and i got the output…the function was working so fine…but the problem is…i cant make the data fixed…that means…user cant edit the displayed data…
[php]
<input name=“prepare_by” value="<?
$sql10=“Select * from employee where ID =’$_SESSION[username]’”;
$query10 = mysql_query($sql10) or die mysql_error());
$result10 = mysql_fetch_assoc($query10);
echo $result10[‘prepare_by’];
?>" />
[/php]
if i do like this the data displayed in the form where u can edit it…and when i took out the form…
[php]

<? $sql10="Select * from employee where ID ='$_SESSION[username]'"; $query10 = mysql_query($sql10) or die mysql_error()); $result10 = mysql_fetch_assoc($query10); echo $result10['prepare_by']; ?>

[/php]
the data displayed without the form and it fixed…so the user cant edit it…but it not stored in the database…it was empty in database…i was confused…i try to google but cant find the answer…anyone out there can help me…thanks in advanced

If you want data to be stored in the database, you’re going to have to use INSERT and UPDATE queries. SELECT won’t cut it.

I think the best way to do this is to SELECT the data about a particular (logged-in) user and load it into a form (in HTML), so it allows to user to change it. Then after submitting the form, you could have PHP pick it up, dump it into an UPDATE query and run that one against the database, effectively updating all of that user’s data.

If you want data to be stored in the database, you're going to have to use INSERT and UPDATE queries. SELECT won't cut it.
i use select not to store the data but to make the data displayed in that form..so i have to select which data to displayed....
I think the best way to do this is to SELECT the data about a particular (logged-in) user and load it into a form (in HTML), so it allows to user to change it. Then after submitting the form, you could have PHP pick it up, dump it into an UPDATE query and run that one against the database, effectively updating all of that user's data.
i cannot simply changed the requirement... have to follow...i cannot change it[/quote]

here i submit the full coding…
[php]

<?php session_start(); include "db1.php"; include "id_generator.php" ?> <?php if (isset($_REQUEST['add'])){ if (!$_REQUEST['company_name'] || !$_REQUEST['prepare_by'] || !$_REQUEST['email'] || !$_REQUEST['emp_1'] || !$_REQUEST['designation'] || !$_REQUEST['department'] || !$_REQUEST['selectmanager'] || !$_REQUEST['purpose'] || !$_REQUEST['pay_to'] || !$_REQUEST['emp_2'] || !$_REQUEST['ecer']) { $display = " *Please Insert All The Particular"; echo $display; } else{ $t_id=$_REQUEST['t_id']; $rec_id=date('r'); $company_name=$_REQUEST['company_name']; $prepare_by=$_REQUEST['prepare_by']; $email=$_REQUEST['email']; $emp_1=$_REQUEST['emp_1']; $designation=$_REQUEST['designation']; $department=$_REQUEST['department']; $selectmanager=$_REQUEST['selectmanager']; $purpose=$_REQUEST['purpose']; $pay_to=$_REQUEST['pay_to']; $emp_2=$_REQUEST['emp_2']; $ecer=$_REQUEST['ecer']; //insert records $query = "INSERT INTO voucher(t_id,rec_id,company_name,prepare_by,email,emp_1,designation,department,selectmanager,purpose,pay_to,emp_2,ecer) values('$t_id','$rec_id','$company_name','$prepare_by','$email','$emp_1','$designation','$department','$selectmanager','$purpose','$pay_to','$emp_2','$ecer')"; $result=mysql_query($query) or die(mysql_error()); $msg="New Record Succesfully Saved "; header("location:detail_2.php?msg=$msg&t_id=$t_id"); } } ?> h3{background-color:#CCCCCC;} .style1 {font-family: Verdana, Arial, Helvetica, sans-serif} .style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; } .style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } detail.php
<td colspan="2">
  <div align="left" class="style4">TRANSACTION CODE:
    <input type="hidden" name="t_id" value="<? echo $t_id; ?>" />
      <?  echo $t_id;?>
  </div></td>

<? //echo $msg=$_REQUEST['msg'];?>
Company Name
  <?php

$sql = “select *from callout”;
$query = mysql_query($sql);
$countData = mysql_num_rows($query);?>
<?php while ($nt=mysql_fetch_array($query))
{
echo "$nt[company] ";
}?>

  <br />
</span></td>
Date <?php echo date("d/m/Y"); ?>
Time <?php echo date ("g:i a"); ?>
Prepare by " />
Email Address " />
Employee No " />
Designation " />
Department "/>
Section/Dept Manager
<span class="style1">
<select  name="selectmanager" size="1" id="selectmanager" />
      
  <?php

$sql = “select *from employee where jb_grade like ‘M%’”;
$query = mysql_query($sql);
$countData = mysql_num_rows($query);?>
<?php while ($nt=mysql_fetch_array($query))
{
echo "$nt[Name] ";
}?>

Voucher details

Purpose
Pay To
Company/Employee No
E-Purchase#/E-CER#

 

[/php][/code]

here the solutions

This an html issue. in the html code put
[php]

[/php] as a parameter for the textbox, textarea, etc you do not want them to edit thanks for the help
this help me to disabled the the form...where user cant edit it...but the data which displayed not stored in database...i trying to pass value using variable....please help me..

i want to pass the value of $company_name=$_POST[‘company_name’];
$prepare_by=$_POST[‘prepare_by’];
$email=$_POST[‘email’];
$emp_1=$_POST[‘emp_1’];
$designation=$_POST[‘designation’];
$department=$_POST[‘department’]; using variable…can anyone help me…tahnks in advanced

[php]
<?php
session_start();
include "db1.php";
include "id_generator.php"
?>
<SCRIPT language=JavaScript type=text/JavaScript>
function check_entry()  
{
   if (form1.purpose.value=="") {
      alert("Please Enter Purpose !");form1.purpose.focus();return false;
   } else {
      if (form1.pay_to.value=="") {
         alert("Please Enter Pay To !");form1.pay_to.focus();return false;
      } else {
      if (form1.emp_2.value=="") {
      alert("Please Enter Employee Number!");form1.emp_2.focus();return false;
      } else {
      if (form1.ecer.value=="") {
      alert("Please eneter Ecer!");form1.ecer.focus();return false;
     } else {
      form1.submit()  
      }
      }
      }
      }
      }

</script>

<?php   

if (isset($_REQUEST['add'])){
    if (!$_REQUEST['company_name'] || !$_REQUEST['selectmanager'] || !$_REQUEST['purpose'] || !$_REQUEST['pay_to'] || !$_REQUEST['emp_2'] || !$_REQUEST['ecer']) 
    {
        $display = "<font face='Verdana' font size='2' font color='#FF0000'> *Please Insert All The Particular";
        echo $display;
             }

        else{
$t_id=$_REQUEST['t_id'];
$rec_id=date('r');
$company_name=$_POST['company_name'];
$prepare_by=$_POST['prepare_by'];
$email=$_POST['email'];
$emp_1=$_POST['emp_1'];
$designation=$_POST['designation'];
$department=$_POST['department'];
$selectmanager=$_REQUEST['selectmanager'];
$purpose=$_REQUEST['purpose'];
$pay_to=$_REQUEST['pay_to'];
$emp_2=$_REQUEST['emp_2'];
$ecer=$_REQUEST['ecer'];
                                        
//insert records    
$query = "INSERT INTO voucher(t_id,rec_id,company_name,prepare_by,email,emp_1,designation,department,selectmanager,purpose,pay_to,emp_2,ecer)
    values('$t_id','$rec_id','$company_name','$prepare_by','$email','$emp_1','$designation','$department','$selectmanager','$purpose','$pay_to','$emp_2','$ecer')"; 
    
$result=mysql_query($query) or die(mysql_error());
$msg="New Record Succesfully Saved ";
header("location:detail_2.php?msg=$msg&t_id=$t_id");
}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
h3{background-color:#CCCCCC;}
.style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
.style3 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; }
.style4 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>detail.php</title>
<link href="payment.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" name="form1" method="post" action="" onSubmit="return check_entry(this);return confirm('Are you  want to save the E-Payment Voucher details ?nnWARNING:nTotal amount must more or equal to RM100.00n You cannot open E-Payment Voucher for total amount less than RM100.00 !!')" onclick=""  >
<table width="545" height="10" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td colspan="2"><? //echo $msg=$_REQUEST['msg'];?></td>
  </tr>
  <tr>
  
    <td colspan="2">
      <div align="left" class="style4">TRANSACTION CODE:
        <input type="hidden" name="t_id" value="<? echo $t_id; ?>" />
          <?  echo $t_id;?>
      </div></td>
  </tr>
  <tr>
  <tr>
    <td width="200"><span class="style3">Company Name </span></td>
    <td width="345"><span class="style3">
      <select name="company_name" size="1" id="company_name"  />
          
      <?php
$sql = "select *from callout";
$query = mysql_query($sql);
$countData = mysql_num_rows($query);?>
      <?php while ($nt=mysql_fetch_array($query))
{
echo "<option>$nt[company] </option> ";
}?>

      <br />
    </span></td>
</tr>

  <tr>
    <td><span class="style3">Date</span></td>
    <td><span class="style3">
      <?php
echo date("d/m/Y");
?>
    </span></td>
  </tr><br />
  <tr>
    <td><span class="style3">Time</span></td>
    <td><span class="style3">
      <?php
echo date ("g:i a");
?>
    </span></td>
  </tr>
  <tr>
    <td><span class="style3">Prepare by</span></td>
    <td><input name="prepare_by" disabled="disabled" value="<? $sql10="Select * from employee where ID ='$_SESSION[username]'";
            $query10 = mysql_query($sql10) or die (mysql_error());
            $result10 = mysql_fetch_assoc($query10);
            echo $result10['Name'];
            ?>"  /></td>
  </tr>
  <tr>
    <td><span class="style3">Email Address</span></td>
    <td><span class="style1">
    <input name="email" disabled="disabled" value="<? $sql10="Select * from employee where ID ='$_SESSION[username]'";
            $query10 = mysql_query($sql10) or die (mysql_error());
            $result10 = mysql_fetch_assoc($query10);
            echo $result10['email'];
            ?>" />
    </span></td>
  </tr>
  
  
  
  <tr>
    <td><span class="style3">Employee No</span></td>
    <td>
    <input name="emp_1" disabled="disabled" value="<?    $sql10="Select * from employee where ID ='$_SESSION[username]'";
            $query10 = mysql_query($sql10) or die (mysql_error());
            $result10 = mysql_fetch_assoc($query10);
            echo $result10['ID'];
            ?>" /></td>
  </tr>
  <tr>
    <td>
    <span class="style3">Designation</span></td>
    <td>
    <input name="designation" disabled="disabled" type="text" id="designation" value="<? $sql10="Select * from employee where ID ='$_SESSION[username]'";
            $query10 = mysql_query($sql10) or die (mysql_error());
            $result10 = mysql_fetch_assoc($query10);
            echo $result10['Designation'];
            ?>" /></td>
  </tr>
  <tr>
    <td>
    <span class="style3">Department</span></td>
    <td
    ><input name="department" type="text" disabled="disabled" id="department" value="<? $sql10="Select * from employee where ID ='$_SESSION[username]'";
            $query10 = mysql_query($sql10) or die (mysql_error());
            $result10 = mysql_fetch_assoc($query10);
            echo $result10['Department'];
            ?>"/></td>
  </tr>
  <tr>
    <td>
    <span class="style3">Section/Dept Manager</span></td>
    <td>
    
    <span class="style1">
    <select  name="selectmanager" size="1" id="selectmanager" />
          
      <?php
$sql = "select *from employee where jb_grade like 'M%'"; 
$query = mysql_query($sql);
$countData = mysql_num_rows($query);?>
      <?php while ($nt=mysql_fetch_array($query))
{
echo "<option>$nt[Name] </option> ";
}?>
    </span></td>
  </tr>
</table>
<h3>Voucher details</h3>
<table width="400" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="200"><span class="style3">Purpose</span></td>
    <td width="200"><textarea name="purpose" id="purpose"></textarea></td>
  </tr>
  <tr>
    <td><span class="style3">Pay To</span></td>
    <td><input type="text" name="pay_to" id="pay_to"></td>
  </tr>
  <tr>
    <td><span class="style3">Company/Employee No</span></td>
    <td><input type="text" name="emp_2" id="emp_2" /></td>
  </tr>
  <tr>
    <td><span class="style3">E-Purchase#/E-CER#</span></td>
    <td><input type="text" name="ecer" id="ecer" /></td>
  </tr>
</table>
<p>
  <input id="add" type="submit" value="Add Item" onclick="main.php" name="add" />
   <input name="reset" type="reset" value="Reset" />

 </p>
<p>&nbsp;</p>
</form>

     
</body>
</html>

[/php]
can anyone give me one example how to pass value to variable according to my coding…thank you…

can anyone help me…for thiis

Google can.

And lookie here.

Seriously, searching for php form tutorial on Google does the trick. We shouldn’t be the ones doing the searching for you.

Sponsor our Newsletter | Privacy Policy | Terms of Service