I think if I am reading your question CORRECT then you need an AJAX call to complete your request to enter.php.
Since you are talking like you want to process your input-data which is in enter.php but user will see the form in index.php and when user submits the form it should post the data to enter.php.
Please use the following code snippet:
index.php
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" language="javascript"></script>
<script language="javascript">
$("#submit_form").submit(function()
{
//check the username exists or not from ajax
$.post("enter.php",{ name:$('#name').val(),surname:$('#surname').val(),rand:Math.random() } ,function(data)
{
if(data) //if correct login detail
{
$("#submit_response").html(data);
}
});
alert("Problem in connecting your server.");
return false;//not to post the form physically
});
</script>
<!-- Show Message for AJAX response -->
<div id="submit_response"></div>
<form id="submit_form" action="javascript:login()" method="post">
<input name="name" type="text" id="name" value=""/>
<input name="surname" type="text" id="surname" value=""/>
<input type="submit" name="Submit" value="Submit"/>
</form>
enter.php
<?php
$nm = $_POST['name'];
$snm = $_POST['surname'];
echo $nm.", ".$snm;
?>
enter.phpopenenter.phpinsideindex.php.