Jump to content

php form help


puja

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
Link to comment
https://forums.phpfreaks.com/topic/8245-php-form-help/
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]
Link to comment
https://forums.phpfreaks.com/topic/8245-php-form-help/#findComment-30045
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
Link to comment
https://forums.phpfreaks.com/topic/8245-php-form-help/#findComment-30049
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
Link to comment
https://forums.phpfreaks.com/topic/8245-php-form-help/#findComment-30093
Share on other sites

Archived

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

×
×
  • Create New...

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.