Link to home
Start Free TrialLog in
Avatar of swpui
swpui

asked on

do not want to refresh screen in php code after back to the webpage

I have a webpage which user can buy goods online, after they order (order.php), they key in their contact (shipping.php), there is a button to link back to the order page in case they change their mind to add on order or to change order. Whenever the user click this button back to the order.php and amend order, then they proceed back to shipping.php again, all the shipping info that the user type in the shipping.php was wipe off, they have to re-type. How should I retain the user shipping info after amending the order and proceed to the shipping page??
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

You need to store the order info in your database and use it to re-populate the form when the shopper goes back to it.  This is pretty standard procedure for any kind of shopping cart.  When the order is finally placed and processed, then you mark it as finished so it doesn't get displayed again.
Avatar of swpui
swpui

ASKER

I saw like Amazon, they retain the username password bcos their user have to create an user account, so this data will be kept in database. My page is much more simple, which I do not require user to create account also can purchase. Beside storing the info to the database, is there any alternative way??
You could store the info in the SESSION. The principle is the same as Dave's suggestion but instead of writing the info to a database, you write it to the SESSION. You will need to include this at the very start of your pages

<?php session_start() ?>

You then set a session variable like so:

$_SESSION['someVariable'] = "Some Value";

You can then echo it back in your form like this:

<input type="text" name="someInput" value="<?php echo $_SESSION['someVariable']; ?>">

That's a very general overview and you'll probably want to read the man pages on session over at php.net:

http://www.php.net/manual/en/book.session.php
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of swpui

ASKER

I will try
@swpui: According to the EE grading guidelines, you are required to explain a marked-down grade.  In this case you left the question open for months without response or comment, then gave the worst grade anyone can give at EE.  Please go back to your history and look at the grades you've been giving.  Out of the last ten questions, you've given only one grade of "A" -- this is unheard of in a forum where the default and expected grade is "A" unless the responses are demonstrably deficient.

Here is your history: https://www.experts-exchange.com/memberQuestionHistory.jsp?mid=3037064

Here are the grading guidelines: http://support.experts-exchange.com/customer/portal/articles/481419

Please furnish your explanation for this, and please read the grading guidelines and take them to heart.  It will make the community more valuable for you if people think you will be a part of the program.

Thanks, ~Ray