-
Advanced PHP Form
Hi all,
I'm trying to develop a fantasy Bike league registration page similar to that of fantasy football. Users pick team members and then earn points when that rider wins a race.
Anyway...
I want users to be able to select six riders from a list with each rider costing a certain amount of "money." The user also has a budget.
After this i want the users name, email and the six riders they have chosen to be submitted into a DB. (mysql)
I have made a mockup in JS that has a similar functionality. (on the real one there will be many more riders and costs will be different)
http://www.dirtyhalfpipe.co.uk/fmtb/ftmb.html
So there should be some form validation that makes sure the user has only selected 6 riders and also that the ones they have chosen add up to be below the budget allowed.
I would really appreciate it if someone could get me going/help me out with this. I have good knowledge of HTML and know bits of PHP. Do you think this (php) is the best way of going about this or are there other methods (online builders, or even flash etc) that I could use instead?
Thanks to anyone that can help,
Sam.
-
-
You have given a lot of great information on what you want, but we need just a little bit more. PHP is great for what you want, but then again I have almost zero experience with ajax or javascript and a fair amount with php.
If it were me designing what you want I would set up 3 separate pages. The first would display the info that was submitted successfully to the database for the user or admin to look at. This page will have the info packaged with some CSS and/or HTML to make it look nice.
The form page will have the form that the user will fill out. Here you will have instructions and use a table with checkboxes so that multiple boxes can be checked. Each checkbox will have a name and a value (whether the box is checked or not). The form will use <form action="submit.php" method="post"> to send the variables to the next page for analysis.
The submit page will check the data to make sure that all of the required fields have been submitted and whether too many checkboxes have been checked or whether the cost of all of the checked checkboxes is over budget. If any of these is not true then redirect back to the form page with a warning saying why the redirect occurred.
I guess the real question is where do you need help or where are you getting stuck?
-
-
Hi James, thanks for the reply.
Your method seems good however there is one thing I can see a problem with. If a user does say select more than 2 checkboxes then they will only find out after submitting the form which means they would have to go back and re-enter all the information again. But then I can see solving this by using something like AJAX or JS will make it alot more complicated plus I don't have great knowledge of either.
To answer your last question I'll tell you what I can do:
I can make the HTML part of the form.
If i can find a decent tut i should also be able to do the php to get it submitted to the next page ready to go into the database.
The main problem is with the on the fly validation and getting the information into the database. And i thought that this subject would affect how the actual form was built so this put me off making a start on it. Just wondering your opinion. No matter how all this is handled will i still need a bog standard html form at the heart? if so I suppose I can get cracking on that and then get back to you.
thanks again for your input,
Sam.
-
-
You can make the form dynamic if you need to, which will be a bit more complicated.
You can use php to redirect back to the form page with the fields filled in with the data that was entered in earlier.
Go ahead and start work on the html part of the form. I am not sure what your understanding of php is. Do you know how to transfer data from one page to another? It can be done using $_GET, $POST (I recommend this one for now), and $_SESSION (which I really only use as a way for users to log in).
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks