Jump to content

DannyZA

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by DannyZA

  1. Greetings, I'm trying to build a system where the superAdmin can add users . I have add_user.php <!--begin::Form--> <form role="form" method="post" action="insert/user.php" class="ajax" id="insert"> <div class="kt-portlet__body"> <div class="form-group row"> <div class="col-lg-6"> <label>Username</label> <input type="text" name="username" id="username" class="form-control input-circle-right" required /> <span class="form-text text-muted">Please enter a valid username</span> </div> <div class="col-lg-6"> <label>Full Name</label> <input type="text" name="firstname" id="firstname" class="form-control input-circle-right" required /> <span class="form-text text-muted">Please add the user's fullname</span> </div> </div> <div class="form-group row"> <div class="col-lg-6"> <label>Password</label> <input type="text" name="password" id="password" class="form-control input-circle-right" required /> <span class="form-text text-muted">Please enter a password for the user</span> </div> <div class="col-lg-6"> <label>Retype Password</label> <input type="text" name="password_again" id="password_again" class="form-control input-circle-right" required /> <span class="form-text text-muted">Please retype the user's password</span> </div> </div> <div class="form-group row"> <div class="col-lg-6"> <label>Email</label> <input type="text" name="email_address" id="email_address" class="form-control input-circle-right" required /> <span class="form-text text-muted">Please enter the user's email address</span> </div> <div class="col-lg-6"> <label>Status</label> <select class="form-control" name="status" id="status"> <option value="A">Active</option> <option value="I">Inactive</option> </select> <span class="form-text text-muted">Please select the status of the user account</span> </div> </div> </div> <div class="kt-portlet__foot"> <div class="kt-form__actions"> <div class="row"> <button type="submit" class="btn btn-primary">Submit</button> <input type="hidden" name="token" value="<?php echo Token::generate() ?>" /> </div> </div> </div> </div> </form> <!--end::Form--> </div> <!--end::Portlet--> </div> </div> <!-- END PAGE CONTENT--> </div> </div> <!-- END CONTENT --></div> <!-- end:: Content --> </div> AND add_user.php //start insert into DB if (Input::exists()) { $response = ""; if (Token::check(Input::get('token'))) { $validate = new Validate(); $validation = $validate->check($_POST, array( 'username' => array( 'required' => true, 'min' => 2, 'max' => 20, 'unique' => 'user_info' ), 'password' => array( 'required' => true, 'min' => 6 ), 'password_again' => array( 'required' => true, 'matches' => 'password' ), 'firstname' => array( 'required' => true, 'min' => 2, 'max' => 50 ) )); if ($validate->passed()) { $userz = new User(); $salt = Hash::salt(32); try{ $userz->create(array( 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password'), $salt), 'salt' => $salt, 'firstname' => Input::get('firstname'), 'surname' => Input::get('surname'), 'group' => 2, 'reg_status' => 'A', 'role' => 'A', 'email_address' => Input::get('email_address') )); $response .= "Success! Thank you."; echo $response; }catch(Exception $e){ $response .= "Failed! Please try again"; echo $response; } }else{ $myArr = array(); foreach ($validate->errors() as $error) { $response .= $error."<br>"; echo $response; } } } }else{ }//end insert into DB The challenge i am facing, when i check on my database table see nothing is added, and i would also like user to get activation code via email after being added. Kindly advise on what i am a programming student and new to PHP
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.