LinuxQuestions.org
Register a domain and help support LQ
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
 
Thread Tools
Old 06-15-2005, 12:56 PM   #1
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 272
Thanked: 0
php in html code


[Log in to get rid of this advertisement]
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 is offline     Reply With Quote
Old 06-15-2005, 01:11 PM   #2
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 272
Thanked: 0

Original Poster
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
blizunt7 is offline     Reply With Quote
Old 06-15-2005, 01:18 PM   #3
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,036
Thanked: 0
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
david_ross is offline     Reply With Quote
Old 06-15-2005, 01:28 PM   #4
Boby
Member
 
Registered: Feb 2004
Location: Sighisoara/Cluj-Napoca (Romania)
Distribution: CentOS 4, Fedora Core 6
Posts: 781
Thanked: 0
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
Boby is offline     Reply With Quote
Old 06-15-2005, 01:45 PM   #5
blizunt7
Member
 
Registered: Mar 2004
Distribution: Fedora Core 1,2,3, RHEL3,4,5 Ubuntu
Posts: 272
Thanked: 0

Original Poster
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
blizunt7 is offline     Reply With Quote
Old 06-15-2005, 02:08 PM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,036
Thanked: 0
You can store data in any file that the webserver has permission to write to.
david_ross is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 06:11 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 02:37 AM
Set up Apache to read php IN html code? WorldBuilder Linux - Networking 10 01-27-2004 01:16 PM
HTML code off pe2338 LQ Suggestions & Feedback 2 08-27-2003 03:03 AM
HTML code is OFF ??? phreakazoid LQ Suggestions & Feedback 5 07-24-2003 01:25 PM


All times are GMT -5. The time now is 06:30 AM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration