Jump to content

Archived

This topic is now archived and is closed to further replies.

puja

php form help

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
looks like you're on the right lines anyway. Your method does the same as mine.

Share this post


Link to post
Share on other sites
Your HTML is not correct. You need an equals sign, "=", after the word "value".

[code]<?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>
?>[/code]

Ken

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[a href=\"http://www.freewebmasterhelp.com/tutorials/phpmysql/5\" target=\"_blank\"]http://www.freewebmasterhelp.com/tutorials/phpmysql/5[/a]

Share this post


Link to post
Share on other sites
sorry just ignore my last reply, putting that = in after value solved the problem!
thanks guys!!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.