0

I want to pass values between 2 HTML pages using POST method. I have lot of data to be passed to 2nd page and cannot use GET. My issue is I do no know how to pass values to second HTML page and how do i display user name on page 2. please explain!!!

Here page1.html code:

<html>
<head>
<title>Form</title>
</head>
<body>
<h4>Enter your name</h4>
<form name="form1" method="post" action="page2.html">
<input type="text" name="username">
<input type="submit" onclick="submitForm()">
</form>
<script type="text/javascript">
  function submitForm()  
   {
     form1.submit();
   }
</script>
</body>
</html>

Here page2.html code:

<html>
<head>
</head>
<body>
....... dont know how to display username entered on page1.html here...
</body>
</html>

1 Answers1

0

Try this

 <html>
 <head>
 </head>
  <body>

 <?php

   if(isset($_POST["username"]))
   {
    echo $_POST["username"];
    }

  ?>
</body>
</html>

And if you want to do this with javascript then readout about AJAX

ajax Tutorial