The following warnings occurred: | ||||||||||||||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
Adding inputs to join.php - Printable Version +- UserSpice (https://userspice.com/forums) +-- Forum: General (https://userspice.com/forums/forumdisplay.php?fid=20) +--- Forum: New to UserSpice? (https://userspice.com/forums/forumdisplay.php?fid=22) +--- Thread: Adding inputs to join.php (/showthread.php?tid=200) Pages:
1
2
|
Adding inputs to join.php - Disruptionz - 08-02-2016 I was following the guide but it seems it is out dated? Could you please tell me how to add new fields please? I'm loving user spice so far. Adding inputs to join.php - Disruptionz - 08-02-2016 For anybody wondering you add to jooin.php Other question is how can i add check boxes? Adding inputs to join.php - dan - 08-02-2016 I am sorry that the guide is outdated. I am out of town but I will try to get it up to date for version 4.1 as soon as possible. Adding inputs to join.php - Disruptionz - 08-03-2016 No Problem, When you can could you tell me how to do check boxes or drop down lists? Adding inputs to join.php - snifer999 - 08-03-2016 ya i too waiting to see how to add a new field in registration form as th current tutorial does not work .... Adding inputs to join.php - dan - 08-04-2016 I'm in the process of moving from Florida to Alaska, but I'm hoping to get some time away tomorrow evening (Eastern Time) to take a look at this. Sorry for the delay. Adding inputs to join.php - dan - 08-05-2016 Today just has not been a good day. I haven't forgotten about you guys though. I'll get back with you. Adding inputs to join.php - Disruptionz - 08-05-2016 @dan I hope the move is going well, If you can help me when you can with the check boxes that would be great. @snifer999 To add inputs you open join.php under users. Look for $lname = Input::get('lname'); and under the list there you add your own so E.G $age = Input::get('age'); under that you will see 'lname' => array( 'display' => 'Last Name', 'required' => true, 'min' => 2, 'max' => 35, ), You add your own E.G 'age' => array( 'display' => 'Age', 'required' => true, (remove this line if it isn't required) 'min' => 2, 'max' => 3, ), Near the bottom you should see try { // echo "Trying to create user"; $user->create(array( 'username' => Input::get('username'), 'fname' => Input::get('fname'), 'lname' => Input::get('lname'), 'email' => Input::get('email'), 'password' => password_hash(Input::get('password'), PASSWORD_BCRYPT, array('cost' => 12)), 'permissions' => 1, 'account_owner' => 1, 'stripe_cust_id' => '', 'join_date' => $join_date, 'company' => Input::get('company'), 'email_verified' => $pre, 'active' => 1, 'vericode' => $vericode, )); I be-leave there you add 'age' => Input::get('age') under fname or email etc.. then under views/ you click open _join.php and add your input <label>Age</label> <input id="age" name="age" type="text" /> To display the field under the user profile you open admin_user.php and add <?=$userdetails->age?> If you want to make it editable you do the following <input class='form-control' type='text' name='age' value='<?=$userdetails->age?>' /> and if you go up the page you will see if ($userdetails->lname != $_POST['lname']){ $lname = Input::get("lname"); $fields=array('lname'=>$lname); $validation->check($_POST,array( 'lname' => array( 'display' => 'Last Name', 'required' => true, 'min' => 1, 'max' => 25 ) )); if($validation->passed()){ $db->update('users',$userId,$fields); $successes[] = "Last Name Updated"; }else{ ?><div id="form-errors"> <?=$validation->display_errors();?></div> <?php } Just add the following under it if ($userdetails->age!= $_POST['age']){ $age = Input::get("age"); $fields=array('age'=>$age); $validation->check($_POST,array( 'age' => array( 'display' => 'Age', 'required' => true, (Delete if not required input) 'min' => 1, 'max' => 3 ) )); if($validation->passed()){ $db->update('users',$userId,$fields); $successes[] = "AgeUpdated"; }else{ ?><div id="form-errors"> <?=$validation->display_errors();?></div> <?php } } Adding inputs to join.php - Kighlander - 10-29-2016 I will try the guide above for my project. But for my project I have an other problem: I need a field, where the user can input his/her birthday, but ONLY if this person's age is 18 or greater, THEN is the input valid. I saw, that there is a validation class, but how works it with my problem ? Can anybody give me a hint ? Greetinxx, Kighlander Adding inputs to join.php - mudmin - 10-29-2016 You would basically have to do your own validation... If this isn't exact, it's close. Notice you can test the logic by using the birthday I commented out instead of the form input.... //date in mm/dd/yyyy format; or it can be in other formats as well //to test it use this line instead of the Input::get line // $birthDate = "12/17/1983"; $birthDate = Input::get('birthDate'); //give your form input a name of birthDate in mm/dd/Y format. //explode the date to get month, day and year $birthDate = explode("/", $birthDate); //get age from date or birthdate $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y") - $birthDate[2]) - 1) : (date("Y") - $birthDate[2])); if($age > 17){ //continue your form processing } else { Redirect::to('join.php?err=Sorry+you+must+be+18+to+join'); }; |