I have 2 screens. 1st is the index.php that have 3 fields. 2 of them should saved to sql and its works fine and the 3rd one should pass the value to 2nd screen. I have JS file. I success doing these 2 operations successfuly but in seperated projects. When I am trying to make them together there are mistakes. I want to know How can I implement those 2 parts together please.
<!DOCTYPE html>
<html>
<head>
<title>PHP MySQL Insert Tutorial</title>
<script src='https://code.jquery.com/jquery-2.1.3.min.js'></script>
</head>
<body>
<form action='insert.php' method='post' id='myform' >
<p>
<input type='text' name='username' placeholder='user name' id='username' />
</p>
<p>
<input type='text' name='password' placeholder='password' id='password' />
</p>
<p>
<input id = "minus" type="text" name="main" value="<?php echo $num1; ?>" autocomplete="off">
</p>
<button id='insert'>Insert</button>
<p id='result'></p>
</form>
</body>
</html>
2nd.php
<?php
session_start();
if(isset($_POST['Submit']))
{
$num_2 = "";
$pass_num = $_POST['main'];
}
?>
<h2>minus</h2>
<br>
<form method="post" action="index.php">
<input type="text" name="state" value="<?php echo $num_2;?>" autocomplete="off">
<br>
<input type="hidden" name="rrr" value="<?php echo $pass_num;?>" autocomplete="off">
<br>
<br>
<input name="Submit" type="submit" value="Submit">
</form>
js
$('#myform').submit(function(){
return false;
});
$('#insert').click(function(){
$.post(
$('#myform').attr('action'),
$('#myform :input').serializeArray(),
function(result){
$('#result').php(result);
}
);
});