The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (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
Adding inputs to join.php
#1
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.
  Reply
#2
For anybody wondering you add to jooin.php

Other question is how can i add check boxes?
  Reply
#3
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.
  Reply
#4
No Problem, When you can could you tell me how to do check boxes or drop down lists?
  Reply
#5
ya i too waiting to see how to add a new field in registration form as th current tutorial does not work ....
  Reply
#6
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.
  Reply
#7
Today just has not been a good day. I haven't forgotten about you guys though. I'll get back with you.
  Reply
#8
@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
}
}
  Reply
#9
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
  Reply
#10
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');
};
  Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)