Jump to content


Photo

php form help


  • Please log in to reply
7 replies to this topic

#1 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 24 April 2006 - 11:01 AM

hi
Ive implemented edit details function but how it works is that when i view the records, there is a link to edit that particular record.
Now that all works fine but when it shows the edit details form, it is empty, is there a way that i can get it to display the information that the record already has and then they can just edit it accordingly rather than having to input all the information again, even the stuff that is already correct?
thanks

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 11:10 AM

As a very rough example...

This will display the values of first_name, last_name and address fetched from a database table.
When you click submit, it will send the updated information to you_update_script.php, which will then use a mysql UPDATE to set the new values to the appropriate record.

If you need further explaination, let me know.

<code]
<?php
// Connect to your database
// Get the details of the record that you want to edit
?>
<FORM METHOD="post" ACTION="your_update_script.php">
<INPUT TYPE="text" NAME="first_name" VALUE="<?php echo '$first_name'; ?>"><br>
<INPUT TYPE="text" NAME="last_name" VALUE="<?php echo '$last_name'; ?>"><br>
<TEXTAREA NAME="address" COLS="35" ROWS="6"><?php echo '$address'; ?><br>
</FORM>
[/code]
wisewood: proven fact, I am both wise, and wooden.

#3 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 24 April 2006 - 11:28 AM

hiya
thanks, i do understand wot ur saying but my form part looks like:

echo '<h2> Edit Customer </h2>
<form action = "edit_cust_details.php" method = "post">
<p>User Name: <input type="text" name ="user_name" size="15" maxlength="15" value"' .$row[0] . '"/></p>
<p>First Name: <input type="text" name ="first_name" size="15" maxlength="15" value"' .$row[1] . '"/></p>
<p>Last Name: <input type="text" name ="last_name" size="15" maxlength="15" value"' .$row[2] . '"/></p>
<p>Email: <input type="text" name ="email" size="15" maxlength="15" value"' .$row[3] . '"/></p>
<p><input type="submit" name="submit" value="Submit" /></p>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="user_name" value="' . $id . '" />
</form>';

so im not sure how i cud include ur suggestion

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 12:34 PM

looks like you're on the right lines anyway. Your method does the same as mine.
wisewood: proven fact, I am both wise, and wooden.

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 24 April 2006 - 02:03 PM

Your HTML is not correct. You need an equals sign, "=", after the word "value".

<?php
 echo '<h2> Edit Customer </h2>
<form action = "edit_cust_details.php" method = "post">
<p>User Name: <input type="text" name ="user_name" size="15" maxlength="15" value="' .$row[0] . '"/></p>
<p>First Name: <input type="text" name ="first_name" size="15" maxlength="15" value="' .$row[1] . '"/></p>
<p>Last Name: <input type="text" name ="last_name" size="15" maxlength="15" value="' .$row[2] . '"/></p>
<p>Email: <input type="text" name ="email" size="15" maxlength="15" value="' .$row[3] . '"/></p>
?>

Ken

#6 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 24 April 2006 - 02:05 PM

ok thank you
i'll put the = in then
and can i get rid of the $row[0] and put in my actual field names instead or wud i need both to try and solve wot i am doing?


#7 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 24 April 2006 - 02:13 PM

[a href=\"http://www.freewebmasterhelp.com/tutorials/phpmysql/5\" target=\"_blank\"]http://www.freewebmasterhelp.com/tutorials/phpmysql/5[/a]
wisewood: proven fact, I am both wise, and wooden.

#8 puja

puja
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 24 April 2006 - 02:13 PM

sorry just ignore my last reply, putting that = in after value solved the problem!
thanks guys!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users