chand
chand

Reputation: 11

Unable to post html page using php

i am new in php.I am trying to send a html registration page in php and want it,s response in another handler.php.But when i lick submit button it is not moving or refreshing

 **Registration.html**

<html >
<form action="handler.php" method="post"  > 
<label>First Name</label>
<input type="text" name="firstname" id="firstname" value="" /> <br/><br/>

<label >Last Name</label>
<input type="text" name="lastname" id="lastname" value=""/> <br/><br/>

<input name="Submit" type="button" value="Submit Details" />
</form>
</html>

**handler.php**
<?php
$FirstName=$_REQUEST['firstname'];
$LastName=$_REQUEST['lastname'];

echo 'welcome'.$FirstName;
?>

Upvotes: 1

Views: 64

Answers (1)

Sunil Pachlangia
Sunil Pachlangia

Reputation: 2061

Change this line

<input name="Submit" type="button" value="Submit Details" />

To

<input name="Submit" type="submit" value="Submit Details" />

Adding Javascript function

<input name="Submit" type="button" value="Submit Details" onclick="submitfunction();"/>

<script type="text/javascript">
function submitfunction()
{
   document.getElementById("YOURFORMID").submit();
}
</script>

Upvotes: 6

Related Questions