View Full Version : where do i program php?

07-07-2005, 01:02 PM
i am a completely noob at php, i only heard of it this morning :p

i have a webpage that uses javascript to use multiple combo boxes and a textarea as part of a form. i need to submit this data to another page and save it in the form of a list. so that it is stored on the page in date order.
i have been told i need to use PHP to do this.

my question is how do i program PHP and where do i do it? does it go in my javascript in script editor or do i need another editor? how do i link to it?

as u can tell i know nothing on this subject so any help would be cool!

07-07-2005, 01:29 PM
You can put PHP anywhere in your page so long as it is in between PHP tags (a little like javascript's <script> tags - PHP tags are <?php code goes in here ?>).

In order to do what you want to do you will need a separate php script that your form submits to (using the action="" element). You can then access all the named form elements using $_POST. This is a cut-down version of how it would work:

// this is your html form
<form name="sendmail" method="post" action="mymail.php"> // the name of your script goes in the action field - mymail.php in this case
<input name="name" type="text" id="name"> name<br />
<input name="email" type="text" id="email"> email<br />
<input type="submit" name="Submit" value="Submit">

// mymail.php

$output = time() . '<br />'; // this creates a timestamp which you can later manipulate to turn into a date
foreach($_POST as $key => $value) {
$output .= "$key = $value<br />";

echo $output;


That's a basic example which just echoes all the data back to your browser window. In order to store the data you need to decide how you want this to happen. You could store the information in one file on your server, or in multiple files or you might want to store it in a database (more useful for manipulating the data) or have the information mailed to your email automatically. Which option you go for will determine how your code will need to look.

The best advice I can give at this point is to google for some basic PHP tutorials and you will soon pick it up, it's not too difficult and what you're asking for is definitely possible.

07-07-2005, 01:34 PM
ok, so the same as having <script></script> i just use php tags withing my script...

i had a look on php.net, do i need to install anything on my pc? the reason i ask is whenever i paste some code into my script, it all appears black and doesnt do much :S

thanks for the reply!

07-07-2005, 01:56 PM
ooo im so confused, this is what ive got...


echo 'hello';

as u can see its sat there in the middle of my page, but i cant see anything when i open the page...what am i doing wrong?
so need to get some books on this i think!!!

07-07-2005, 01:57 PM
You won't be able to view it on your PC unless you install PHP on your home machine. You will need to make sure that your web server supports PHP and you will also need to save your files with a ".php" extension instead of the usual .htm or .html - this tells the server to run the page as a PHP script.

The easiest way to test if your server supports PHP is to create a page with the following contents:

Then browse to that page - if your server is PHP-enabled you will see a whole lot of information about the configuration. If you don't have PHP on your server you'll probably just see the code appear as text.

07-07-2005, 02:04 PM
man, im showing my complete lack of knowledge here....

so i type that into a new html page, then save it as *.php, save it to my website, then i go to that page via IE?

im soooo confused :D

EDIT: i have tried this and it loads up a notepad file with the code in it...

07-07-2005, 02:36 PM
Double check the extension for the file is .php and not .txt - if it's still not working then it looks like your host doesn't allow PHP, you will need to see if it's something they offer as an extra or find a new host.

You can still install PHP on your PC and use that to practice writing scripts until you have the hosting situation resolved, but I've never done that so I couldn't tell you how easy it is. I think firepages has some packages that make this easier on his site, there is a sticky about it in the main forum here (http://www.codingforums.com/showthread.php?t=3992) if you want to take a look.

07-07-2005, 02:42 PM
yeah, i guess its my server thats the issue.

i could do with getting installed locally tho, its annoying that what im trying to do will only work with php yet i cant get it working!
ive downloaded some files for php but none seem to have an installer or anything i recognise as being useful. if theres anyone willing to guide me thru this process i would be muchos grateful...

thanks guys

07-07-2005, 03:12 PM
If you wanna run webserver software (Apache, PHP etc) on your computer you can either download each item or you can download an apache distro such as XAMPP which installs it all for you :)

07-07-2005, 03:17 PM
A link to phpdev is right on this forum, phpdev doesn't need to be configured.

07-07-2005, 03:17 PM
here's a link to a tutorial to guide you through the installation process, I used this and it worked a treat,
good luck!

07-07-2005, 03:44 PM
okay, lets do this RARGHH....*cough*

well...the website looks handy so giving that a go, hopefully i will get further than i did trying on me own.


EDIT: ok so im looking at this and Apache needs my domain name etc, trouble is i am on a LAN and my boss probly wont want me to do anything on his web server, is there a way to get PHP working on my machine first then put it on the server if he thinks its worth it?

07-07-2005, 05:37 PM
If you get the phpdev package from firepages and install it on your machine you'll have everything you need. Basically you have to edit the httpd.conf file in a couple places to tell it where your webroot is on your local machine (where ever your site files are located). There are a couple of batch files that will be on your start menu, you just pick the one that goes with your OS, and run it. That will start Apache and open your homepage in your browser. From there you can view php in action as you develop your site.

If you plan on uploading this to a webserver or you lan, you need to make sure it is running Apache otherwise it will not serve your pages correctly (just like your machine won't until you have Apache running).

Just read the getting started docs that come with it and you'll be in good shape.

07-08-2005, 10:08 AM
mothra, hey man, thanks, didnt see those bits in the start menu.
opened it up and hey presto i see the php stuff, now its just a matter of figuring out which string to change in the .conf file to point at the file which has all the website stuff.

cheers for all the help guys, i feel like im getting somewhere!

EDIT: i did it, ooo i have a warm fuzzy feeling inside! now the hard bit :eek: