LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php in html code (https://www.linuxquestions.org/questions/programming-9/php-in-html-code-333906/)

blizunt7 06-15-2005 11:56 AM

php in html code
 
Hey all,
I am a newbie to web serving. Have gotten apache installed, and working. My website is up (currently within my LAN specifically), but i am trying to work with PHP so i can allow visitors to interact with the site, and i can record some data on my server.

I am have much trouble getting php working. I have tried simply to put a php script in my html as follows:
<?php
echo "helllo world";
?>

Nothing.
This is embeded in my index.html file which is located in /var/www/html

I have tried to installed php on my machine, and I thought i did i right. ANyone know how to check the php installation, and incorrporate it with apache??

I added the line:
Loadmodule php4_module modules/libphp4.so

even thought $php -v returns PHP 5.0.4

THanks so much!!!!

blizunt7 06-15-2005 12:11 PM

ohhh, when i changed the index.html file to index.php, the little php script worked, and the site remained the same. THis is correct?????? Now lets say i want to use forms, how would i included an external php script so i can capture use input in the index.html file???

THanks again,
josh

david_ross 06-15-2005 12:18 PM

You will need to use the php extension unless you want to parse all .html files on your site.

If you want to get values that are posted to a php script then use the $_POST["field_name"] variables:
http://www.php.net/manual/en/languag...predefined.php

Boby 06-15-2005 12:28 PM

Hello blizunt7!

Quote:

ohhh, when i changed the index.html file to index.php, the little php script worked, and the site remained the same. THis is correct??????
Yes! :)


PHP Code:

<?php
// Here you get your values
if($_POST['submit'])
{
     
$firstName $_POST['firstname'];
     
$lastName $_POST['lastname'];

     echo 
"Your first name is "$firstName ." and your last name is "$lastName ."!!!";
}
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" name="post" id="post">

First Name:<input type="text" size="15" maxlength="50" name="firstname" value="Enter your first name here" /><br />
Last Name:<input type="text" size="15" maxlength="50" name="lastname" value="Enter your last name here" /><br /><br />
<input type="submit" name="submit" />&nbsp;&nbsp;
<input type="reset" name="submit" />
</form>

Boby

blizunt7 06-15-2005 12:45 PM

THANKS!, that helps very much so, one last issue. HOw can I determine where on my server (what directory/file) to store this data in, and can i simply append more data to the end???

JOsh

david_ross 06-15-2005 01:08 PM

You can store data in any file that the webserver has permission to write to.


All times are GMT -5. The time now is 09:57 AM.