Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:24:34+00:00 2026-06-04T01:24:34+00:00

I am learning php and html. I am trying to make a function run

  • 0

I am learning php and html.

I am trying to make a function run when a submit button is pressed. Then I want it to edit a text field on my form with the variable from that function. Without going to a new page…like a self refresh.

How do I do this? Thanks.

I think I have seen how to do this with JavaScript getelementbyID. But I need to do it via php.

Perhaps an easy way to explain it is this: When button is pressed it generates a password in a text field automatically.

The function I am using:

<?
function genkey($length){
    $key = '';
    list($usec, $sec) = explode(' ', microtime());
    mt_srand((float) $sec + ((float) $usec * 100000));

    $possibleinputs = array_merge(range('z','a'),range(0,9),range('A','Z'));

    for($i=0; $i<$length; $i++) {
        $key .= $possibleinputs{mt_rand(0,61)}; }
    return $key;
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:24:35+00:00Added an answer on June 4, 2026 at 1:24 am

    like this:

    //    index.php
    <?php
    function genkey($length){
        $key = '';
    list($usec, $sec) = explode(' ', microtime());
    mt_srand((float) $sec + ((float) $usec * 100000));
    
    $possibleinputs = array_merge(range('z','a'),range(0,9),range('A','Z'));
    
    for($i=0; $i<$length; $i++) {
        $key .= $possibleinputs{mt_rand(0,61)}; }
    return $key;
    }
    
    $data = array();
    if( !empty($_POST['variable']) ) {
        $data['variable'] = genkey( strlen($_POST['variable']) );
    } else {
        $data['variable'] = '';
    }
    ?>
    //...HTML...
    <form action="" method="POST">
    <input name="variable" value="<?=$data['variable']?>">
    <input type="submit" value="toPHP">
    </form>
    //...HTML...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning php, trying to use the fopen() function. The php file I
I want to make a tech news website. I started learning PHP, and since
I am learning php, html and css now and I'm trying to use a
I am learning PHP, and I'm trying to make an application that has a
So I'm learning some php and found my html skills more then a little
I'm learning how to use PHP. I'm trying to run a simple PHP script.
I'm learning PHP. The PHP has inline commands in HTML code to produce dynamic
I am learning scraping using the PHP Simple HTML DOM Parser and Xpath. Accroding
I'm a student learning PHP. I basically make the stuff work, but never wondered
I'm still learning php and have run up against what should be a relatively

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.