I've got a form, with just normal <input type="text"> its already in a form. But what I want to do, is having a randompassword generator to generate a password for the password field. The button needs to activate a script and put the value into the password field.
but its not possible to submit a form in a form right?
example code:
<?php
//password gen
if (isset($_POST['passgen'])) {
$charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$generated_password = substr(str_shuffle($charset), 0, 12);
}
//password gen end
?>
<form action="index.php" method="POST">
<input type="submit" name="submit-form-with-text" value="submit form"/>
<input type="submit" name="activate-the-passgen" value="Generate a password"/>
<input type="text" value="<?php echo $generated_password; } ?>" size="15" />
</form>