Hello ive got a login screen user logs in then they should be able to update there details there orignal details appear in textboxes so i want the user to be able to edit there old details in the textboxes and update them but dont understand how can i update them details. ive got abt 5textboxes that the user can update thanks

mysql_query("UPDATE StudentRecords SET Telephone = '$Telephone'
WHERE Email= '".$_SESSION['myusername']."'");
10 Years
Discussion Span
Last Post by blocblue

Hi Aran87,
I would use an HTML template, with placeholders in the code. E.g.

<form method="post" action="foobar.php">
<input class="text_field" name="surname" type="text" value="{SURNAME}" />
<input class="button" name="submit" type="submit" value="Update Details" />

The simplest method would then be to read the template into a PHP variable using file_get_content, and query your database for the users details. You could then use str_replace to substitute the users current details in for the tags, so replace {SURNAME} with the surname result (obviously). And finally print that to the screen.

The user will be able to edit the details within the text boxes, and you can harvest the new values by selecting them from the $_POST array. E.g. $surname = $_POST['surname']; You can also use this method for validating the data the user has entered, and redisplaying it onscreen with an error message or specific highlighting if anything fails.

Sorry if this response was condesending. I wasn't sure how much detail you wanted/needed.

Hope this helps.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.