Forgotten Password form - Yii2 - Basic - email

I need a clue how to have a Forgotten email "form" that send code to some user(email box) and when he click the "code" for resetting the password,he is redirecting in the website and then he update his "forgotten password" , I make forgot.php page in "site" folder , but can someone give me some clue what must be the logic in the SiteController and etc.
forgot.php (form for the forgotten password)
<h1><?= Html::encode($this->title) ?></h1>
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'email') ?>
<div class="form-group">
<div class="col-lg-offset-1 col-lg-11">
<?= Html::submitButton('Submit', ['class' => 'btn btn-primary'])?>
</div>
</div>
<div>
<?php ActiveForm::end(); ?>

In Controller:
check user in db by email from the above email form, isExist?
exist -> generate reset_token+timestamp, and send email to user link+token+timestamp+email
User access the link, show form for new password + repeat password. But you need to set token validity by time (ex: 30 minutes).
if token valid, user can change password. else, redirect to page reset again

Related

How can i vaalidate Google reCaptcha on HTML form submit button

I have used following form:
`
<fieldset>
<div class="zl-form-captcha">
<div class="g-recaptcha" data-sitekey="my-key" style="text-align: center;"></div>
</div>
</fieldset>
<fieldset>
<p style="text-align: center;"><button name="submit" type="submit" id="contact-submit" data-submit="...Sending" class="wpcf7-form-control wpcf7-submit btn">Submit</button></p>
</fieldset>
`
How can i validate google captcha form before form submit?
Thanks.
You cannot validate captcha on the client (browser), so you cannot validate it before submit.
Captcha validation has to be done on the server, after the form is submitted, as it involves calling google with their API to validate that the captcha was answered correctly Refer to this page on how to do this verification: https://developers.google.com/recaptcha/docs/verify.

Laravel 5.1 password reset email to existing email in DB

I am a novice web developer. I am following the password reset tutorial for laravel 5.1 found here
Currently the default view they are listing in their documentation asks the user to type his/her email into the form. I was wondering how I could just set the reset email using the users email I already have in my DB and posted to the URL the form below has.
I can get the logged in users email like this:
App\User::find(Auth::user()->id)->email
the form
<form method="POST" action="dashboard/password/email">
{!! csrf_field() !!}
#if (count($errors) > 0)
<ul>
#foreach ($errors->all() as $error)
<li>{{ $error }}</li>
#endforeach
</ul>
#endif
<div>
Email
<input type="email" name="email" value="{{ old('email') }}">
<!-- how can I just use the email I have in my DB instead of input-->
</div>
<div>
<button type="submit">
Send Password Reset Link
</button>
</div>
</form>
I know it must be quite simple, can anyone help me with this novice problem?
Keep in mind that everything else about resetting the password is default Laravel solution from the documentation.
Thank you for any kind of help :)
EDIT!!!
when I set it to hidden like:
<input type="hidden" name="email" value="{{ App\User::find(Auth::user()->id)->email }}">
I get an error:
Swift_TransportException in AbstractSmtpTransport.php line 162:
Cannot send message without a sender address
So the form is not posting the email

Need save button to save and then redirect

I need to add a redirect to the button, so when users click the save button for the update profile page it redirects them to the updated profile
<input type="hidden" name="submitted" id="submitted" value="true"/>
<button class="btn form-submit" id="edit-submit" name="op" value="Publish Ad" type="submit"><?php _e('Save', 'agrg') ?></button>
Please Help
You should do this on server side.
You can do this using PHP like that :
<?php header('Location: http://www.your-website.com/your/path'); ?>
and the user will be redirected to /your/path.
Documentation available here.

InStock QTY to be display after Login

I am new to Magento, In my site i want to display the categories after login, but for some categories its displaying before login and some of the categories are unable to see the In Stock after login also. Can any one please help me on this.
Thanks in Advance
I don't know if i understand your question completely, but i think you want to show your categories only after the user is logged in?
You could only show the category menu after login using
<?php if ($this->helper('customer')->isLoggedIn() ): ?>
<-- Place the things you want the show here! -->
<?php endif ;?>
So if you use this in the topmenu (app/design/frontend/yourpackage/yourtheme/template/catalog/navigation/top.phtml) it would look like this
<?php if ($this->helper('customer')->isLoggedIn() ): ?>
<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
<?php endif ;?>

Form Field - Enter Part of URL and go to Full URL Destination

How to create a form field where the user enters in part of a URL and then clicks to visit that full URL?
Example. [type our company name here].website.com (Submit Button) -> goes to companyname.website.com
I need the full code snippet for this one, from to please. Thank you for your help.
In HTML/PHP you can do :
HTML Form :
<form method="post" action="target.php">
<input type="text" name="beforeUrl" />.website.com
<input type="submit" value="Click here" />
</form>
PHP :
<?php
header('Location: http://'.$_POST['beforeUrl'].'.website.com');
?>
PS : It's basic code but you do protect your POST var.