helper.php
<?php
function h()
{
$randomchar = str_shuffle('abcdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ234567890!$%^&!$%^&');
$password = substr($randomchar, 0, 12);
$generated_pass = $password;
}
view
<input type="text" id="lname" name="pass" value="<?php echo $generated_pass;?>"><br><br>
error ErrorException
PHP 8.1.12
9.48.0
Undefined variable $generated_pass
tried to do it like above but got error.
2
Answers
functions should return its local value:
then you should call function:
I think you need to call the function instead.
<input type="text" id="lname" name="pass" value="<?php echo h(); ?>"><br><br>
Also make sure that the helper.php file is loaded.