-
Posts
85 -
Joined
-
Last visited
Everything posted by ankh2054
-
Hi all, I am trying to create a if else statement to show a default image if no image is uploaded. image field = avatar (maximum files allowed set to 1) Below is the full code now. The code below does not output "this is a test" if the image field is not populated. <?php // Run through all images and set thumbnail foreach($user->avatar as $image) { $thumb = $image->size(142); } //Check if avatar field contains a value if (isset($thumb)){ $avatar_thumb .= "<img class='img-rounded img-responsive' src='{$thumb->url}'' alt='{$thumb->description}'' />"; } else { $avatar_thumb .= "This ia a test"; } ?> <!--Display Avatar image--> <div class="user-image"> <?php echo $avatar_thumb; ?> </div>
-
thanks that did the trick. The code is used: foreach($user->avatar as $image) { $large = $image->width(500); $thumb = $image->size(100, 100); $avatar_thumb = "<img class='img-circle' src='{$thumb->url}'' alt='{$thumb->description}'' />"; } <div class="user-image"> <?php echo $avatar_thumb; ?> </div>
-
Hi All, I am trying to allow users to upload a profile image. What I've done: Created a new field (crop image) called "avatar" and added this to the users template Using the code shown below I can successfully upload images. What I'm not sure of how is: Is the field type correct and best way How to display the thumbnail of the image once uploaded thanks <?php $upload_path = $config->paths->assets . "files/avatar_uploads/"; $f = new WireUpload('avatar'); $f->setMaxFiles(1); $f->setMaxFileSize(5*1024*1024); $f->setOverwrite(true); $f->setDestinationPath($upload_path); $f->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); if($input->post->form_submit) { if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } $files = $f->execute(); if ($f->getErrors()) { foreach($files as $filename) @unlink($upload_path . $filename); foreach($f->getErrors() as $e) echo $e; } else { //$u = $users->get($user); //$u = $user->name; //Save the photo to the avatar field $user->of(false); $user->avatar = $upload_path . $files[0]; $user->save(); $user->of(true); @unlink($upload_path . $files[0]); } } ?> <form class="forum-form" accept-charset="utf-8" action="./" method="post" enctype="multipart/form-data" > <input type="file" id="attach" name="avatar" multiple="multiple" accept="image/jpg,image/jpeg,image/gif,image/png" /> <input type="submit" name="form_submit" value="Submit"/> </form>
-
Hi All, My login form below. When a user tries to login more than twice in a very short time the following errors is displayed. Exception: Please wait at least 5 seconds before attempting another login. processwire I have read a post which states you can capture that error message display it to the user using, but I'm not sure exactly how to use this. Would someone be so kind and offer assistance. try { // Login } catch (WireException $e) { // Print out message of exception echo $e->getMessage(); } <?php $login_errors = ""; $out = ""; $form = "<form class='omb_loginForm' action='./' accept-charset='UTF-8' autocomplete='off' method='POST'> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='user' placeholder='Username'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='pass' placeholder='Password'> </div> <span class='help-block'></span> <button class='btn btn-lg btn-primary btn-block' type='submit' name='login_submit' value='Login'>Login</button> </form>" ; //Check if user is already logged in - redirect to if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/"); } //check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; $u = $users->get($user); //Check if the password provided in $pass equals tmp_pass if($u->id && $u->tmp_pass && $u->tmp_pass === $pass) { // user logging in with tmp_pass, so change it to be their real pass $u->of(false); $u->pass = $u->tmp_pass; $u->save(); $u->of(true); $u = $session->login($user, $pass); if($u) { // user is logged in, get rid of tmp_pass $u->of(false); $u->tmp_pass = ''; $u->save(); // now redirect to the profile edit page $session->redirect('/reset-pass-change/'); } } //if user not logging if with TMP password carry on as normal. try { if($session->login($user, $pass)) { $session->redirect("/"); } else { $login_errors = "Username or Password is incorrect"; $out .= $form; } } catch (Exception $e) { $login_errors = $e->getMessage(); } /*If user not logging if with TMP password carry on as normal. elseif($session->login($user, $pass)) { // login successful $session->redirect("/"); } else { $login_errors .= "Username or Password is incorrect"; $out .= $form; }*/ } else { $out .= $form; } ?> <?php include("./head.inc"); ?> <?php include("./navbar_login.inc"); ?> <div class="container"> <div class="omb_login"> <h3 class="omb_authTitle">Login or <a href="/register/">Sign up</a></h3> <div class="row omb_row-sm-offset-3 omb_socialButtons"> <div class="col-xs-4 col-sm-2"> <a href="#" class="btn btn-lg btn-block omb_btn-facebook"> <i class="fa fa-facebook visible-xs"></i> <span class="hidden-xs">Facebook</span> </a> </div> <div class="col-xs-4 col-sm-2"> <a href="#" class="btn btn-lg btn-block omb_btn-twitter"> <i class="fa fa-twitter visible-xs"></i> <span class="hidden-xs">Twitter</span> </a> </div> <div class="col-xs-4 col-sm-2"> <a href="#" class="btn btn-lg btn-block omb_btn-google"> <i class="fa fa-google-plus visible-xs"></i> <span class="hidden-xs">Google+</span> </a> </div> </div> <div class="row omb_row-sm-offset-3 omb_loginOr"> <div class="col-xs-12 col-sm-6"> <hr class="omb_hrOr"> <span class="omb_spanOr">or</span> </div> </div> <div class="row omb_row-sm-offset-3"> <div class="col-xs-12 col-sm-6"> <div class="alert alert-error fade-in alert-dismissable"> <!-- error outputs --> <?php echo $login_errors; ?> </div> <!-- Form outputs --> <?php echo $out; ?> </div> </div> <div class="row omb_row-sm-offset-3"> <div class="col-xs-12 col-sm-3"> <label class="checkbox"> <input type="checkbox" name="rememberme" value="1" checked="checked">Remember Me </label> </div> <div class="col-xs-12 col-sm-3"> <p class="omb_forgotPwd"> <a href="/reset-pass/">Forgot password?</a> </p> </div> </div> </div> <?php include ("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
Integrating a member / visitor login form
ankh2054 replied to thetuningspoon's topic in General Support
thanks Ryan for the thorough tutorial -
Accessing user fields before use is logged in
ankh2054 replied to ankh2054's topic in API & Templates
thanks Pete, makes sense -
Hi All, I have a user field called user_activation (textfield), which contains an activation code. The user receives a email with an activation code, upon when clicked changes that field to a value of "0". I want to check that field before a user logs in, but unsure how to access that field without the user actually being logged in. Using the below code, the field always returns NULL. <?php $login_errors = ""; $out = ""; $form = "<div class='omb_login'> <h3 class='omb_authTitle'>Login or <a href='/register/'>Sign up</a></h3> <div class='row omb_row-sm-offset-3 omb_socialButtons'> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-facebook'> <i class='fa fa-facebook visible-xs'></i> <span class='hidden-xs'>Facebook</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-twitter'> <i class='fa fa-twitter visible-xs'></i> <span class='hidden-xs'>Twitter</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-google'> <i class='fa fa-google-plus visible-xs'></i> <span class='hidden-xs'>Google+</span> </a> </div> </div> <div class='row omb_row-sm-offset-3 omb_loginOr'> <div class='col-xs-12 col-sm-6'> <hr class='omb_hrOr'> <span class='omb_spanOr'>or</span> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-6'> <form class='omb_loginForm' action='./' accept-charset='UTF-8' autocomplete='off' method='POST'> <div class='alert alert-error fade-in alert-dismissable'> </div> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='user' placeholder='Username'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='pass' placeholder='Password'> </div> <span class='help-block'></span> <input class='returnUrl' type='hidden' name='returnUrl' value='[[+request_uri]]' /> <input class='loginLoginValue' type='hidden' name='service' value='login' /> <button class='btn btn-lg btn-primary btn-block' type='submit' name='login_submit' value='Login'>Login</button> </form> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-3'> <label class='checkbox'> <input type='checkbox' name='rememberme' value='1' checked='checked'>Remember Me </label> </div> <div class='col-xs-12 col-sm-3'> <p class='omb_forgotPwd'> <a href='[[~5]]'>Forgot password?</a> </p> </div> </div>" ; //Check if user is already logged in - redirect to if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/"); } //Check if submit is issued if($input->post->login_submit) { /*check for login before outputting markup if($input->post->user && $input->post->pass) { */ $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; var_dump($user->user_activation); /*if(strcmp($user->user_activation, 'test') == 0){ /*if($user->user_activation != 0) { $login_errors .= "Sorry, but you need to activate your account!"; $out .= $form; } elseif($session->login($user, $pass)) { // login successful $session->redirect("/"); } else { $login_errors .= "Username or Password is incorrect"; $out .= $form; } */ } else { $out .= $form; } ?> <?php include("./head.inc"); ?> <?php include("./navbar_login.inc"); ?> <div class="container"> <div><?php echo $login_errors; ?></div> <?php echo $out; ?> </div> <?php include ("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
I see what the problem is now, it always returns NULL, because it cannot access the user field. I guess it doesn't now which user you want to access. Doing a var_dump($user->user_activation); returns NULL
-
Lol I really am such a PHP newbie, thanks for all your help. What happens is the following: During registration a activation code is set for the user. $p = new Password(); $activation = $p->randomBase64String(100); // 100=length of string $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; Then an email is send to the user with the activation link, when clicked the below is executed. $activate_username = $sanitizer->text($_GET['user']); $activate_hash = $sanitizer->text($_GET['hash']); if(wire("users")->get($activate_username)->id) { if(strcmp(wire("users")->get($activate_username)->user_activation, $activate_hash) == 0 || wire("users")->get($activate_username)->user_activation == 0) { echo "Your account has been activated!<br><br>"; $activate_user = wire("users")->get($activate_username); $activate_user->of(false); $activate_user->user_activation = "0"; $activate_user->save(); } else { echo "There was an error activating your account! Please contact us!<br><br>"; } } else { echo "Sorry, but that we couldn't find your account in our database!<br><br>"; } This then changed the value to 0. Should I change this, or could I check against that value of 0? thanks again for your help.
-
It is a text field added to the systems default user template.
-
If I change if($user->user_activation != 0) { echo "Sorry, but you need to activate your account!"; } TO if($user->user_activation == 0) { echo "Sorry, but you need to activate your account!"; } Then no users can login, even if that field does == 0. Does anyone have any ideas?
-
I have now changed my code to the below, so the form displays, but it does not stop the user from logging in if user_activation != 0. Any ideas? I have checked the user field in the backend, and it still contains the activation code. <?php $login_errors = ""; $out = ""; $form = "<div class='container'> <div class='omb_login'> <h3 class='omb_authTitle'>Login or <a href='#'>Sign up</a></h3> <div class='row omb_row-sm-offset-3 omb_socialButtons'> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-facebook'> <i class='fa fa-facebook visible-xs'></i> <span class='hidden-xs'>Facebook</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-twitter'> <i class='fa fa-twitter visible-xs'></i> <span class='hidden-xs'>Twitter</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-google'> <i class='fa fa-google-plus visible-xs'></i> <span class='hidden-xs'>Google+</span> </a> </div> </div> <div class='row omb_row-sm-offset-3 omb_loginOr'> <div class='col-xs-12 col-sm-6'> <hr class='omb_hrOr'> <span class='omb_spanOr'>or</span> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-6'> <form class='omb_loginForm' action='./' accept-charset='UTF-8' autocomplete='off' method='POST'> <div class='alert alert-error fade-in alert-dismissable'> </div> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='user' placeholder='Username'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='pass' placeholder='Password'> </div> <span class='help-block'></span> <input class='returnUrl' type='hidden' name='returnUrl' value='[[+request_uri]]' /> <input class='loginLoginValue' type='hidden' name='service' value='login' /> <button class='btn btn-lg btn-primary btn-block' type='submit' name='submit' value='Login'>Login</button> </form> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-3'> <label class='checkbox'> <input type='checkbox' name='rememberme' value='1' checked='checked'>Remember Me </label> </div> <div class='col-xs-12 col-sm-3'> <p class='omb_forgotPwd'> <a href='[[~5]]'>Forgot password?</a> </p> </div> </div> </div>" ; // Check if user is already logged in - redirect to if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/"); } //Check if submit is issued if($input->post->submit) { //check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($user->user_activation != 0) { $login_errors .= "Sorry, but you need to activate your account!"; $out .= $form; } elseif($session->login($user, $pass)) { // login successful $session->redirect("/"); } } } else { $out .= $form; } ?> <?php include("./head.inc"); ?> <?php include("./navbar.inc"); ?> <div><?php echo $login_errors; ?></div> <?php echo $out; ?> <?php include ("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
Hi all, I have been working on a login form using the following article from Kyle: https://processwire.com/talk/topic/4066-activate-user-account-via-email/ I cannot seem to get the form to output an error if the user is not activated, as it stands now my page does not load and gives an error, stating an unexpected { at line 104. <?php $login_errors = ""; $out = ""; $form = "<div class='container'> <div class='omb_login'> <h3 class='omb_authTitle'>Login or <a href='#'>Sign up</a></h3> <div class='row omb_row-sm-offset-3 omb_socialButtons'> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-facebook'> <i class='fa fa-facebook visible-xs'></i> <span class='hidden-xs'>Facebook</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-twitter'> <i class='fa fa-twitter visible-xs'></i> <span class='hidden-xs'>Twitter</span> </a> </div> <div class='col-xs-4 col-sm-2'> <a href='#' class='btn btn-lg btn-block omb_btn-google'> <i class='fa fa-google-plus visible-xs'></i> <span class='hidden-xs'>Google+</span> </a> </div> </div> <div class='row omb_row-sm-offset-3 omb_loginOr'> <div class='col-xs-12 col-sm-6'> <hr class='omb_hrOr'> <span class='omb_spanOr'>or</span> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-6'> <form class='omb_loginForm' action='./' accept-charset='UTF-8' autocomplete='off' method='POST'> <div class='alert alert-error fade-in alert-dismissable'> </div> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='user' placeholder='Username'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='pass' placeholder='Password'> </div> <span class='help-block'></span> <input class='returnUrl' type='hidden' name='returnUrl' value='[[+request_uri]]' /> <input class='loginLoginValue' type='hidden' name='service' value='login' /> <button class='btn btn-lg btn-primary btn-block' type='submit' name='submit' value='Login'>Login</button> </form> </div> </div> <div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-3'> <label class='checkbox'> <input type='checkbox' name='rememberme' value='1' checked='checked'>Remember Me </label> </div> <div class='col-xs-12 col-sm-3'> <p class='omb_forgotPwd'> <a href='[[~5]]'>Forgot password?</a> </p> </div> </div> </div>" ; // Check if user is already logged in - redirect to / if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/"); } //Check if submit is issued if($input->post->submit) { // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($user->user_activation != 0) { $login_errors .= "Sorry, but you need to activate your account!"; $out .= $form; } //Below is line 104 with the else statement. else($session->login($user, $pass)) { // login successful $session->redirect("/"); } } } else { $out .= $form; } ?> <?php include("./head.inc"); ?> <?php include("./navbar.inc"); ?> <div><?php echo $login_errors; ?></div> <?php echo $out; ?> <?php include ("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
I have have updated my code and my working register.php for user registration is above for anyone else. Thanks Kyle and Kongondo for your help. Original article used: https://processwire.com/talk/topic/4066-activate-user-account-via-email/
-
thanks I've removed the sanitzation.
-
Hi found the problem, the below works. WOW I'm so proud, now onto the next steps. <?php include("./functions.php"); $error = false; // form was submitted so we process the form if($input->post->submit) { //Sanatize and assign variables data before creating user. $username = $sanitizer->username($input->post->username); $email = $sanitizer->email($input->post->email); $password = $sanitizer->text($input->post->password); $full_name = $sanitizer->text($input->post->full_name); //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->save(); $new_user->of(true); } ?> <?php include("./head.inc"); ?> <?php include ("./navbar.inc"); ?> <div class="container"> <div class="row omb_row-sm-offset-3"> <div class="col-xs-12 col-sm-6"> <form class="omb_loginForm" action="./" accept-charset="UTF-8" autocomplete="off" method="post"> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" class="form-control" name="username" placeholder="Username"> </div> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" class="form-control" name="full_name" placeholder="Full Name"> </div> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-envelope"></i></span> <input type="text" class="form-control" name="email" placeholder="Email"> </div> <span class="help-block"></span> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-lock"></i></span> <input type="password" class="form-control" name="password" placeholder="Password"> </div> <span class="help-block"></span> <button class="btn btn-lg btn-primary btn-block" type="submit" name="submit" value="register">Register</button> </form> </div> </div> </div> <?php include("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
If logged in as admin, I get the below error. Call to a member function processInput() on a non-object (line 11 of /var/www/www.bommachine.co.uk/site/templates/register.php)
-
Hi all, Wonder if anyone can help me troubleshoot the below. I am working on a user registration form and I am taking it step by step. The form displays but once I press submit I get a server error. Could anyone help me with troubleshooting this. I created a custom error log file for the sire, but nothing is logged apart from the GET and POST request. <?php require_once("/usr/share/php/PHPMailer-master/PHPMailerAutoload.php"); include("./functions.php"); include("./head.inc"); include("./navbar.inc"); $out = ""; $errors = ""; $form= "<div class='row omb_row-sm-offset-3'> <div class='col-xs-12 col-sm-6'> <form class='omb_loginForm' action='./' accept-charset='UTF-8' autocomplete='off' method='post'> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='username' placeholder='Username'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-user'></i></span> <input type='text' class='form-control' name='full_name' placeholder='Full Name'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-envelope'></i></span> <input type='text' class='form-control' name='email' placeholder='Email'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='password' placeholder='Password'> </div> <span class='help-block'></span> <div class='input-group'> <span class='input-group-addon'><i class='fa fa-lock'></i></span> <input type='password' class='form-control' name='password_confirm' placeholder='Confirm Password'> </div> <span class='help-block'></span> <button class='btn btn-lg btn-primary btn-block' type='submit' name='submit' value='register'>Register</button> </form> </div> </div>" ; if($input->post->submit) { //instantiate variables taking in the form data $username = $sanitizer->username($input->post->username); $email = $sanitizer->email($input->post->email); $password = $input->post->password; $full_name = $sanitizer->text($input->post->full_name); /* * Create the activation code * You can add a random string onto the * the username variable to keep people * from cracking the hash * ex $activation = md5($username."processwire"); */ $p = new Password(); $activation = $p->randomBase64String(100); // 100=length of string $activation_code = $config->httpHost."/activation/?user=".$username."&hash=".$activation; //check for errors on the form //Check if all the fields have been inputted if (empty($input->post->username) || empty($input->post->email) || empty($input->post->password)) { $errors .= "Please fill out all fields marked with a *"; $out .= $form; } //check if a valid email address was provided elseif (!filter_var($input->post->email, FILTER_VALIDATE_EMAIL)) { $errors .= "Please include a valid email address"; $out .= $form; } //Check to ensure both passwords match elseif($input->post->password !== $input->post->password_confirm) { $errors .= "Please ensure both Passwords match"; $out .= $form; } //Check to ensure password is complex enough elseif (!preg_match("/[0-9]/", $input->post->password) || strlen($input->post->password) < 6) { $errors .= "Please ensure your password has at least one digit and is at least 6 characters long"; $out .= $form; } /* * this checks to makesure that no one has the username * I have a functions file that I import to the pages I * need it on (funcions.php) */ elseif(username_validation($username) == 0) { $out .= $form; if(strlen($username) != 0){ if(username_validation($username) == 0) { $username->error = " "; $errors .= "Sorry that username is already taken!"; } } } //the registration was successful else { $out = "Thank you for registering!<br><br>"; $out .= "An email has just been sent to " . $email . " with the url to activate your account<br><br>"; $out .= "Click here to continue to login"; /* * In this example I am using phpmailer to send the email * I prefer this, but you can also use the mail() function */ $mail = new PHPMailer(); $mail->IsHTML(true); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "smtp.smtp.com"; // SMTP server $mail->From = "test@test.com"; $mail->FromName = "Register @ Test"; $mail->AddAddress($email); $mail->AddReplyTo("test@test.com","Register @ Test"); $mail->Subject = "Registration"; $mail->Body = " Hi " . $full_name. ", <br>" . "Thanks for registering at Your Site. To activate your email address click the link below! <br><br>" . "Activation Link: <a href='http://".$activation_code."'>".$activation_code."</a>"; $mail->send(); //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->user_activation = $activation; $new_user->save(); $new_user->of(true); } } //form not submitted else { $out .= $form; } ?> <div class="container"> <div><?php echo $errors; ?></div> <?php echo $out; ?> </div> <?php include("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
Get username from form and adding to $username variable. $username = form->get("username");
-
Hold on, am I not assigning the variables. Sorry this is internal dialogue on the tube. What if I do. $username = $input->post->username
-
It's saying I have a empty name field, so I'm clearly missing something. Error: Exception: Can't save page 0: /d1scordia8/access/users//: It has an empty 'name' field (in /var/www/www.bommachine.co.uk/wire/core/Pages.php line 604)
-
So I have created this.... clearly not working, but could anyone point me in the right direction. <?php $form = array( 'full_name' => $input->post->full_name, 'username' => $input->post->username, 'password' => $input->post->password, 'email' => $input->post->email, ); if($input->post->submit) { //create the new user $new_user = new User(); $new_user->of(false); $new_user->name = $username; $new_user->email = $email; $new_user->pass = $password; $new_user->addRole("guest"); $new_user->user_full_name = $full_name; $new_user->save(); $new_user->of(true); } ?> <?php include("./head.inc"); ?> <?php include ("./navbar.inc"); ?> <div class="errors"><?php echo $errors; ?></div> <div class="container"> <div class="row omb_row-sm-offset-3"> <div class="col-xs-12 col-sm-6"> <form class="omb_loginForm" action="./" accept-charset="UTF-8" autocomplete="off" method="POST"> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" class="form-control" name="username" placeholder="Username"> </div> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span> <input type="text" class="form-control" name="full_name" placeholder="Full Name"> </div> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-envelope"></i></span> <input type="text" class="form-control" name="email" placeholder="Email"> </div> <span class="help-block"></span> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-lock"></i></span> <input type="password" class="form-control" name="password" placeholder="Password"> </div> <span class="help-block"></span> <input class="loginLoginValue" type="hidden" name="submit" value="submit" /> <button class="btn btn-lg btn-primary btn-block" type="submit" name="submit" value="register">Register</button> </form> </div> </div> </div> <?php include("./foot.inc"); ?> <?php include ("./java.inc"); ?>
-
thanks Kongondo most helpful. I just need to get my head around it all then it should be easier. Im being impatient