The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
additional registration fields cleared on submit - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28) +--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29) +--- Thread: additional registration fields cleared on submit (/showthread.php?tid=1507) |
additional registration fields cleared on submit - eric - 06-01-2019 The concept of usersc/scripts/additional_join_form_fields.php works great, but I am having trouble with the two parts of validation. My fields get validated before submit, but on submit the original user form fields get validated, like username and email, and all my additional field inputs are gone if there is an error. That is, the user fills out the complete registration page, including the standard fields and my additional fields, the validation confirms all my required fields, but on submit they lose their additional field inputs. I think it's because my fields are validated when the submit button is pressed but prevent the form contents from being posted, but the original user registration form fields are validated only after being posted. At that point, the error messages are displayed at the top, but all my additional form fields are now blank. (I have several fields because they are essentially applying to register). Is there an additional step I'm missing? Eric RE: additional registration fields cleared on submit - mudmin - 06-01-2019 Hi Eric. I want to make sure I understand your question. Are you saying that the inputs themselves are gone or the data the people typed in the inputs are gone? RE: additional registration fields cleared on submit - eric - 06-01-2019 (06-01-2019, 09:24 PM)mudmin Wrote: Hi Eric. I want to make sure I understand your question. Are you saying that the inputs themselves are gone or the data the people typed in the inputs are gone? Good clarification. The input fields are still there, but they are cleared. RE: additional registration fields cleared on submit - mudmin - 06-01-2019 Ok. So what you want to do is let's say you have a text field of "address" You would do <input type="text" name="address" value="<?php if(!empty($_POST['address'])){echo $_POST['address'];}> I think that's it. I'm not in my code editor, but the idea is that if a form has been posted, you need to re-echo whatever they put in the form field if it fails validation. RE: additional registration fields cleared on submit - eric - 06-02-2019 (06-01-2019, 10:50 PM)mudmin Wrote: Ok. So what you want to do is let's say you have a text field of "address" That makes perfect sense. I wasn't thinking about it already being in the $_POST variable. I tried a couple fields as a test, and it's working perfectly - thank you for the help and the quick response! I'm happy I made the choice to build on userspice! |