Page 1 of 1

How to include PHP in HTML

Posted: Mon May 25, 2009 12:22 pm
by Sosi
Hello!
I have a html file that has forms and some submit buttons.

I want that html page to show some information that is executed from a PHP code but I dont know how to do it... (how to maintain the looks of the html page and return the result of the PHP script?)

I think it should be something like this:

Code: Select all

 
<?php
include('config.php');
?>
<html>
<head>
<title>Personal INFO</title>
</head>
<body>
<form method="post" action="<?php echo $PHP_SELF;?>">
First :<input type="int" size="12" maxlength="12" name="Fname"><br />
</form>
<?php
 
$Fname = $_POST["Fname"];
$Lname = $_POST["Lname"];
 
 
$nome = mysql_query("SELECT * FROM `names` WHERE id =".$Fname."");
$array = array();
 
$coiso= mysql_fetch_array($nome);
array_push($array,$coiso);
 
print_r($array);
?>
</body>
Thanks a lot! :)

Re: How to include PHP in HTML

Posted: Tue May 26, 2009 8:11 am
by oliur

Code: Select all

 
 
<?php
if(isset($_POST['your_button_name'])){
 
//process submitted data
$firstName = $_POST['firstName_txt'];
$secondName = $_POST['secondName_txt'];
 
//connect to database...
//run sql...
} 
//if form has'nt been submitted,  show this form
 
else{
?>
 
//your form
 
<?php 
    } //end of if 
?>
 
 
 
 
[/color]