| 4:52 am on Jul 22, 2007 (gmt 0)|
|So how would the following process take place best with php and mysql? |
If the visitors do have Username and password, let them login and save whatever actions they make into the database. Query the database for simple displaying, query the database to add new rows or update.
If they don't have a username, provide session values, and follow the same process of adding, updating and displaying data from the database.
If this doesn't answer your question, you need to be a little bit more specific of what you exactly need.
| 7:22 pm on Jul 22, 2007 (gmt 0)|
Let me summarize how I think things work, feel free to correct.
A form is created and handled in stages. First, it is created. After submission it is re-created with any error messages or sent to the next step of displaying the information then uploading it.
Do you have a normal html header and put all the php in the body?
| 7:27 am on Jul 23, 2007 (gmt 0)|
Temporarily form values can be stored in a session [php.net] to retain the information so that if the form needs to be edited for whatever reason it can be without having to rekey the info again. Once the user is sure that they want to submit the data, the information can be placed in the database. Refer to the mysql documentation [php.net] for related functions.
| 7:58 am on Jul 23, 2007 (gmt 0)|
I think what I'm struggling with is the basic design philosophy. From the simple examples I've looked at, it seems I should build a single page with several functions.
The first function would run writing the first form. A second function would run if a hidden form input in the first form is found in $_POST, checking the inputs of the first form.
Somehow, a third function would re-write a second for, a forth function would check that, and so on until the end where the last function would use the form inputs to build a 'review' page where the user could either go back for corrections or upload the form into a database where it would feed a page.
Is this correct? I've experimented using variables to keep track of what functions has run, but I must misunderstand php variables because it wasn't working...
I'm also missing a number of other design techniques that are hard to figure out by reading php documentation but if I understand the basic mechanisms I could mush more easily know what to look for.
I've only found one good example on onlamp.com It confuses me though. I tryed the code copy / past but I think my local server must have different setting or the code is not complete because it doesn't work like it does on their page.
With sessions would I use multiple pages maintaining inputs within the session?
| 8:10 am on Jul 23, 2007 (gmt 0)|
I think you are making this more complicated than it should be. Try starting as basic as you can get and then add onto what you have built already. Some additional resources that you may find useful:
Dealing with Forms [php.net]
Variables from outside PHP [us.php.net]
| 11:03 am on Jul 23, 2007 (gmt 0)|
I think your absolutely right eelixduppy, I came to that conclusion laying in bed a few hours ago.
I need to do some simple experimentation.
| 4:38 am on Jul 24, 2007 (gmt 0)|
Ok, I've made some progress and have a couple specific questions.
1. How do I stop the form process when an error condition is found?
2. What is a good way to arrange things so that error appear under each input?
Here is the code. My current problem is that the page processes before the error displays.
// Verify something has been inputed
if (strlen(trim($input)) <= 5) return 1;
else return 0;
print "<form name='form1' id='form1' enctype='multipart/form-data'
action = 'breeder-list-2.php' method = 'post' />";
print "<input type='text' name='name' size='20' value='' />";
print "<input type='submit' name='submit' value='submit' />";
print "<input type='hidden' name='_submit_check' value='1' />";
print "Input Nam";