hello! i have here a code

<?php
include("include/session.php");
?>

<?php


echo $session->username;
$sql = "select * from employee where fname like 'pedro'"; // CONNECT KO TO DAPAT SA FORM KO NA SEARCH-FORM
$result=mysql_query($sql);
$num=mysql_num_rows($result);
$row = mysql_fetch_array($result);
//mysql_close();
if($row) {
$i=0;
while ($i < $num) {
    $empnumber = $row[0];
    $fname=$row[1];
    $mname=$row[2];
    $lname=$row[3];
    $homeadd=$row[4];
    $emailadd=$row[5];
    $ofcnum=$row[6];
    $mobilenum=$row[7];
    $homenum=$row[8];
    $position=$row[9];
    $practice=$row[10];
    $projname=$row[11];
    $projmgr=$row[12];
    $teamlead=$row[13];

    $i = $i + 1;
    }
 }
    ?>
<html><br />
<form>
<body>
<font style="bold">
Employee Number:<input name="emp_number" type="text" value="<?php echo $empnumber; ?>" readonly="readonly" />
<br />
First Name:<input name="fname" type="text" value="<?php echo $fname; ?>" readonly="readonly"/>
<br />
Middle Name:<input name="mname" type="text" value="<?php echo $mname; ?>" readonly="readonly"/>
<br />
Last Name:<input name="lname" type="text" value="<?php echo $lname; ?>" readonly="readonly"/>
<br />
Home Address:<input name="homeadd" type="text" value="<?php echo $homeadd; ?>" readonly="readonly"/>
<br />
Email Address:<input name="emailadd" type="text" value="<?php echo $emailadd; ?>" readonly="readonly"/>
<br />
Office/project number:<input name="ofcnum" type="text" value="<?php echo $ofcnum; ?>" readonly="readonly"/>
<br />
Mobile Number:<input name="mobilenum" type="text" value="<?php echo $mobilenum; ?>" readonly="readonly"/>
<br />
Home number:<input name="homenum" type="text" value="<?php echo $homenum; ?>" readonly="readonly"/>
<br />
Position:<input name="position" type="text" value="<?php echo $position; ?>" readonly="readonly"/>
<br />
Practice:<input name="practice" type="text" value="<?php echo $practice; ?>" readonly="readonly"/>
<br />
Project Name:<input name="projname" type="text" value="<?php echo $projname; ?>" readonly="readonly"/>
<br />
Project Manager:<input name="projmgr" type="text" value="<?php echo $projmgr; ?>" readonly="readonly"/>
<br />
Team Leader:<input name="teamlead" type="text" value="<?php echo $teamlead; ?>" readonly="readonly"/>
<br> 
<input type="submit" name="edit" value="Edit" />
<input type="submit" name="update" value="Update" action="update.php" />
<input type="submit" name="delete" value="Delete" action="delete.php"/>
</br>
</form>
</body>
</html> 

can you please help me with a code for the button that if i click it, the text boxes will be enabled?

Thanks!

There is no readonly attribute in an <input type="text" field. There is disabled="disabled".

re-edit: I may be incorrect. :-(

I am indeed incorrect. Another thing learnt today.

You will need to use JavaScript - are you using any jQuery? (I prefer jQuery).

Hi paulkd!

i dont know how to use jQuery :(

Member Avatar

diafol

You don't have to use jQ, but it certainky makes life easier if you don't know js.

You could do something like this in ordinary js, but I'm a little rusty :(

<input name="practice" type="text" value="<?php echo $practice; ?>" disabled="disabled"/>
<button id="edit">"Edit"</button>

<script type="text/javascript">
    document.getElementById('edit').onclick=function(){

        var inputs = document.getElementsByTagName('input'); 
        for(var k=0;k<inputs.length;k++){ 
           inputs[k].disabled = false; 
        } 

    };
</script>

JUST be aware that disabling or readonly-ing will not give you any protection against users sending malicious values. You cannot trust the data - ever.

I totally agree with diafol and have said it on another thread - never trust client side validation, always validate server side. It's so easy to manipulate forms with Firebug and/or chrome developer tools.

@mallows.yum what is the purpose of the form?

You are performing a LIKE search to return more than one record, but your form is designed for one record only.

paulkd,

i havent fixed that yet. i'll do it today. :)

diafol, i'll try your code. but how will i do that for all the textboxes? :)

Thanks

Member Avatar

LastMitch

diafol, i'll try your code. but how will i do that for all the textboxes? :)

You need to add a <form> name & id to get all input tags in the form.

hi LastMitch,

so i will name my form. uhm id for every textbox is it?

Member Avatar

LastMitch

uhm id for every textbox is it?

Why an id **for every **textbox?

<input name="practice" type="text" value="<?php echo $practice; ?>" disabled="disabled"/>

You already have name which is "practice" why add an id?

This is what I meant

<form name ="anyname" id="anyid" action="#">
 <input name="practice" type="text" value="<?php echo $practice; ?>" disabled="disabled"/>
</form>