newbie80 Posted December 11, 2012 Share Posted December 11, 2012 Could really do with some help. I am trying to put together a basic form (I am a complete newbie) where users go onto a webpage that I have made and enter their email address which is then checked against database to a) see if it has already been entered, in which case I will show a message and B) return a value from the database list at random (I want to populate a database column with around 30 values and when user enters their email it shows them a value from this list at random but is also unique, i.e. no one else can be given that value. Can someone help? I don't know where to begin. Really appreciate it! Quote Link to comment https://forums.phpfreaks.com/topic/271873-simple-form-help/ Share on other sites More sharing options...
Christian F. Posted December 12, 2012 Share Posted December 12, 2012 (edited) This isn't a PHP problem as much as it's an "Application design" problem, so you should really have posted it in that section. A mod will probably move it for you, once they notice it. That said, to your question: You should start with the planning phase, always. Which means you'll need to sit down, think through exactly what you want from the site, what you need to do to get those results, and what data you need in order to do it. Take a piece of paper, or several, and start with the headings; The big stuff, the end results of what you want to have on it. To take this forum for example, we've got the headings of "forum", "members page", "member administration", "private messages", "profiles", and "recent content". To take a few. Once you've got that down, you can start to drill down in more detail on what you want to have on each section. Such as "categories", "sub categories", "threads", and "posts", taking the "forum" section as an example. Filling out all of the small parts, in ever increasing detail, until you've sketched out everything you want/need. By now you should have a pretty complete list of headings, telling you what you want, and in a large part what kind of data you need. The next step is to define the logic needed to get the results needed from the data, which I tend to write down as a keyworded bullet list. Mostly using a single verb and one noun to describe what needs to be done, and the flow of logic between the steps. Using the "new post" item as the example, you can get a list pretty much like this: - Verify access. - If submitted. - Retrieve & validate data. - If validation failed. - Create validation warning message. - Prefill input values. - Show form + error. - Return. - Create query. - Execute query. - If query failed. - Create critical error message. - Prefill input values. - Show form + error. - return - Redirect to confirmation page (view new thread). - Read form template file. - Prefill input values, if any. - Show form. Once that's done, you should have a pretty much complete understanding of the logic in the application. An understanding which will make a lot easier to translate your pseudo-code into actual PHP, as you've already solved most (if not all) of the problems you had; Without ever introducing an actual programming language into the confusion. That is, paradoxically enough, what programming is mostly about. Edited December 12, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/271873-simple-form-help/#findComment-1398876 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.