The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
multiple select box or checkboxes in the registration form
#3
Ok. This is not super elegant, but it doesn't require you to update the user class.
http://hastebin.com/toyaxagipu.xml

Let me walk you through it.

1. This file goes in the usersc folder as join.php. This is good practice and stops our updates from breaking your modifications. Note that I copied the original join form and changed the paths to all the includes.

2. I got rid of the "view" and made the entire join form one big file for simplicity.

3. I added 3 checkboxes at the bottom of the form beginning on line 268. One to show you're over 18(over_18), one to show you love userspice(love_us), and one to show that you are human(am_human).

4. I comment in the form how you could store this info in a different db table, but I'm going to work on the assumption that you are going to want it in the users table, so I added 3 more columns with a type of varchar 5 and called them over_18, love_us, and am_human. Note that I'm also leaving the checkboxes to their default value which means that if a box was checked, it will show up in the database as a string of 'on' and if it was empty, that will be null in the database. If you want to change that, you can do some logic before the array to update the databsae.

5. This is not neat, but it's clear. On line 195, after the user is created, I am going back and running a query to find the user's id that we just inserted. We get that id on line 199.

6. Now I'm creating an array of which field names and which information I want to put into the database. As I commented on in the document, if you are storing this info in a table other than users, you are going to want to include the user id along with the checkbox info, so you know who the info belongs to.

I hope this helps. Let me know if you have any questions.
  Reply


Messages In This Thread
multiple select box or checkboxes in the registration form - by mudmin - 11-11-2016, 02:37 PM

Forum Jump:


Users browsing this thread: 3 Guest(s)