Calling php script from within html

pint7x

Registered user
Joined
May 11, 2008
Messages
901
Reaction score
0
Location
Svalbard
Does anyone out there have any experience of either

a) embedding php (php hypertext preprocessor) in html code or

b) calling some php code from within html code?

I am creating a website for a friend and using some code I got from my html book. What I'm trying to do is have the user fill in various on-screen fields, then use the php code to generate and send an email.

Both the html code and php code are very short, but for some reason it ain't working. I don't think the php code is being called 'cos it certainly ain't generating an email.

I would think there's probably one or two very small things I've got wrong in the code, but I'm buggered if I can find them.

Is there anyone out there who could take a look at some bits of code and let me know what I'm doing wrong please?

Rather than cut 'n' paste the code here, probably easier to do it via PM or email.

Thanks in advance

cheers - Phil - 6X
 
Both the html code and php code are very short, but for some reason it ain't working. I don't think the php code is being called 'cos it certainly ain't generating an email.

Stupid question... are you running it on a hosting service or locally (PC)?

John
 
Stupid question... are you running it on a hosting service or locally (PC)?

John

Not stupid at all! I'm running the website on a hosted server which I know supports PHP.

I know that PHP runs on the server, whereas HTML will always get pushed out to the client.

I guess what I need to know is: If my website contains 10 pages, each of which is HTML, how do I make the one HTML page which needs to call the PHP do so, 'cos if the HTML is running client side, it'll just ignore the command because it can't see the PHP code.

Do all my web pages need to run server side? i.e. do they all need to be PHP extension?

Cheers - Phil
 
Do all my web pages need to run server side? i.e. do they all need to be PHP extension?
I don't know PHP other than have had a look at an example

It looks like any other form of server side preprocessor, so I'd imagine they should only need to be .php files if they contain PHP code - the server will process that and produce "standard" html for rendering client-side.
 
PHP

Not stupid at all! I'm running the website on a hosted server which I know supports PHP.

I know that PHP runs on the server, whereas HTML will always get pushed out to the client.

I guess what I need to know is: If my website contains 10 pages, each of which is HTML, how do I make the one HTML page which needs to call the PHP do so, 'cos if the HTML is running client side, it'll just ignore the command because it can't see the PHP code.

Do all my web pages need to run server side? i.e. do they all need to be PHP extension?

Cheers - Phil

Hi Phil,

I have built such a form, (copied an example from elsewhere).
You create a 'form' on a standard html page (e.g. Contact.html), which collects the data you want to capture, plus a button.
When the button is pressed, you call (POST) to another file (e.g. feedback.php) and pass it the fields from your form. This then runs feedback.php on the server, sends an email etc. and then in turn calls another html page (e.g. Thankyou.html) when done.
If you are still having problems, PM me and i will send you some sample html and php via email.

Regards

Chris
 
Check your server supports smtp php if it doesn't then it wont do anything. PHP has a myriad of options when its setup and for various reasons not all servers have all options.
 
Phil- I had a nightmare trying to get this sort of thing working on the old version of my website-
in the end, I used some stuff from HERE, in particular the page HERE and a wizard they have on that site somewhere...it worked very well.

I can send you the URLs of the pages I had up and working so you can look at the page view and see all the code if you like :thumb2

The other thing I'd seriously recommend is looking at building this site with Wordpress...that's what I've built the new one with and it's very easy to use, has more plugins and templates (all free) and so on than pretty much anything else and can be used to produce some very nice sites, pretty weasily after the initial steep learning curve of getting a my SQL server up and running with WP installed on it.
 
thesitewizard

thesitewizard.com is the example I based my pages on.
It's a really good resource and the wizard for the feedback form is a very good start for building such a page.

regards

Admiral
 


Back
Top Bottom