0

i have below code for store and set field value

<!DOCTYPE html>
<html>
    <head>
        <title>hjdsjhdsf</title>
    </head>
    
    <body>
        <form name="nn" method="post">
            <input type="text" name="name" onsubmit="kou()" id="tt">
            <input type="submit" name="kk">
        </form>
    </body>
</html>

<?php
   function kou(){
       $Ul =$_POST['name'];
       echo "<script>document.getElementById('tt').value=' . $Ul . ';   </script>";
   }
   
   $UM =$_POST['name'];
   
  if(array_key_exists('name', $_POST)){
      ECHO "SDHDJ";
      echo $UM;
  }

?>

when user submit the form, when there is errors all conditions are shows, But user enter details are all gone. i want set what user enter value to set the same field as value

  • 1. Input does not have onsubmit, the form element has. 2. JS cannot execute a PHP function just by running it. You need AJAX. Perhaps you mean `` – mplungjan Jul 09 '23 at 07:42

0 Answers0