Welcome visitor
* Login
* Register
It is currently March 19th, 2019, 7:51 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Server Side » PHP



Post new topic Reply to topic  [ 2 posts ] 
Author Message
  autofill a form when editing an existing user data
PostPosted: February 20th, 2009, 1:01 am 
User avatar

Posts: 44
Hey there,

I have a form to register a new user, but what can i do to use the same form and at the same time show the existing info, in case that it is an already existing user who is editing his profile?

This is what i have to register the new user:
echo '<form method="POST" action="?pag=newAdd">
        <b>Name: </b><input type="text" name="userName"><br /><br />
        <b>Address: </b><input type="text" name="userAddress"><br /><br />
        <b>Phone: </b><input type="text" name="phoneNumbr"><br /><br />
        <input type="submit" value="Send"></form><br /><br />';


Tell me if you need more information, thanks.


Top
 Profile  
 
  Re: autofill a form when editing an existing user data
PostPosted: February 20th, 2009, 1:15 am 
User avatar

Posts: 137
u can set that the value for each field to be the existing info of the user, something like this (you will need to change the name for the variables, maybe, according to the name of the fields in tha db)
echo '<form method="POST" action="?pag=newAdd">
    <b>Name: </b><input type="text" name="userName" value="'. $name . '"><br /><br />
    <b>Address: </b><input type="text" name="userAddress" value="'. $address . '"><br /><br />
    <b>Phone: </b><input type="text" name="phoneNumbr" value="'. $phone . '"><br /><br />
    <input type="submit" value="Send"></form><br /><br />';

of curse u need to validate if it is an existing user and have all its related info ready to go... cheers.
also, i suppose that u already know that it is not the same to update info than adding a completely new row, note that im taking for granted that you have the users info on a db.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

FORUMS » Server Side » PHP


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron