I am learning PHP. Need a basic help. I want to create a html page where I input data. When confirmed key is pressed it will take to a php page where entered data wll be shown and there will be a edit button.I can easily do it upto this.
Now which I cant do is:
when edit button will be pressed it wil take to a different php page which is similar to first page but all input fields will be prefilled with the data entered and I will be able to edit the data.
If someone can help me giving an example of only one field, then it wil be great.
Thanks a lot
NEED HELP CREATING PHP SESSION
Moderator: General Moderators
- mecha_godzilla
- Forum Contributor
- Posts: 375
- Joined: Wed Apr 14, 2010 4:45 pm
- Location: UK
Re: NEED HELP CREATING PHP SESSION
Assuming you've captured the form values correctly you can then pre-populate the text fields using this sort of code:
Alternatively, if you want to use sessions instead you need to add session_start() to the top of both pages, then on your first page do this:
then on your second page do this:
Is that what you need?
HTH,
Mecha Godzilla
Code: Select all
$my_value = $_POST['my_value'];
echo 'Your value is: <input type="text" name="my_value" value="' . $my_value . '" /><br />';
Code: Select all
$_SESSION['my_value'] = $_POST['my_value']Code: Select all
$my_value = $_SESSION['my_value'];
echo 'Your value is: <input type="text" name="my_value" value="' . $my_value . '" /><br />';HTH,
Mecha Godzilla
Re: NEED HELP CREATING PHP SESSION
Thank you. It has really helped.