Page 1 of 1

How to refresh PHP page with data in fields without submitti

Posted: Tue Mar 21, 2006 2:01 pm
by solarisuser
Hello,

I have a PHP page that has input text boxes and dropdown menus. Sometimes, users will input data and realize that one of the dropdown menus does not have the data they need. So they will click on a hyperlink next to the dropdown menu, and add it to the MySQL DB.

The problem is, the new data in the MySQL DB which shows up in the dropdown menu does not show up unless the user refreshes the page, but all the data they already put in is lost.

Is there any way to deal with this issue?

Thanks in advance!

Posted: Tue Mar 21, 2006 2:07 pm
by feyd
A thread from today.
viewtopic.php?t=45858

Posted: Tue Mar 21, 2006 8:29 pm
by gavinandresen
I have a PHP page that has input text boxes and dropdown menus. Sometimes, users will input data and realize that one of the dropdown menus does not have the data they need. So they will click on a hyperlink next to the dropdown menu, and add it to the MySQL DB.
Well... you could use AJAX, but unless you're already using AJAX that would be a ton of work.

Can you change the UI a bit? Instead of clicking on a hyperlink next to the drop-down, click on a special selection in the drop-down? E.g. (new value) ? Then if (new value) is set when the form is submitted, give them a form where they can enter the new info and submit it. You could bundle up all the other values from the first form into a hidden field on the second ( htmlspecialchars(serialize($_POST)) would work).

If THAT's too much work, you could keep the hyperlink and have them choose a (new value) selection that just tells your PHP code to re-display the form with all the $_POST'ed values filled in (and the new value from the DB, assuming they followed the hyperlink and added another choice).

This code might be helpful with the re-display the form part of the problem: http://www.onlamp.com/pub/a/php/2006/03 ... forms.html
[/quote]