简体   繁体   中英

call php function on form submition

Hi im trying to generate this a code from this php function

         <?php function generateRandomString($length = 6) {
    return substr(str_shuffle(str_repeat($x='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length/strlen($x)) )),1,$length);
}

echo  generateRandomString(); ?>

when this <button>Submit</button> is clicked. It is a submition button for a form in HTML

Many Thanks in advance:)

For help on the basics of setting up a form in HTML: https://www.w3schools.com/html/html_forms.asp

You'll need to target your PHP script in the form action. https://www.php.net/manual/en/tutorial.forms.php

Using the script exactly as you have it will simply send the plain text random string back to your browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM