I am very new to PHP and HTML as well. I have written html code to read first name and last name as:
<!DOCTYPE html>
<html>
<body>
<form action="welcome.php" method="post">
First Name: <input type="text" name="Fname"><br>
Last Name: <input type="text" name="Lname"><br>
<input type="submit">
</form>
</body>
</html>
and I am calling welcome.php
to insert some values into database as below.
<html>
<body>
Welcome <?php echo $_POST["Fname"]; ?>
<?php $db = pg_connect("host=localhost port= dbname= user= password="); ?>
<?php $query = "INSERT INTO employee VALUES ('sasi','kala')"; ?>
<?php $result = pg_query($query); ?>
?>
<a href="first.html"></a>
</html>
</body>
when I open html file by chrome browser, I am getting 2 fields as FirstName
and LastName
. After entering details and click on submit button, nothing is getting displayed or executed in php. If i remove html and body tag from php file, entire code is getting displayed on browser.How can i run this PHP script from HTML using my web browser. Any installation needed? Am i doing anything wrong. I am executing this code in windows web browser. Can anyone tell me the procedure?