LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-15-2005, 11:56 AM   #1
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

Rep: Reputation: 30
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!!!!
 
Old 06-15-2005, 12:11 PM   #2
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

Original Poster
Rep: Reputation: 30
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
 
Old 06-15-2005, 12:18 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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
 
Old 06-15-2005, 12:28 PM   #4
Boby
Member
 
Registered: Feb 2004
Posts: 781

Rep: Reputation: Disabled
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
 
Old 06-15-2005, 12:45 PM   #5
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 274

Original Poster
Rep: Reputation: 30
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
 
Old 06-15-2005, 01:08 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You can store data in any file that the webserver has permission to write to.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
html code and including html files Hockeyfan Programming 2 08-22-2005 05:11 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Set up Apache to read php IN html code? WorldBuilder Linux - Networking 10 01-27-2004 12:16 PM
HTML code off pe2338 LQ Suggestions & Feedback 2 08-27-2003 02:03 AM
HTML code is OFF ??? phreakazoid LQ Suggestions & Feedback 5 07-24-2003 12:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration