0

As I said, all the html files are set up. The site uses mostly jquery mobile, and I first tried to use coldfusion. However, this created a lot of problems, as I couldn't change the filetypes form .html to .cfm without creating a lot of problems. All I need to do is validate a couple fields, and email it to myself. is there a good way to do this without changing much of the existing code?

I've been looking at PHP, but I'm new to server-side scripting, so I'm not sure what's required. Will this only work if the server AND each machine has php installed, or does the server just have to have PHP?

Thanks for your help!

4

2 に答える 2

3

Simple answer, only the server hosting the pages will need PHP. Is the server running IIS, Apache or like?

Using Apache as an example, you can do something like:

AddType application/x-httpd-php .php .htm .html
AddHandler x-httpd-php .php .htm .html

This will tell Apache to treat all .html and .htm files as PHP. If there is no PHP within the files, it will server just the HTML, which means no issues for you on files which dont need to be changed.

Before I forget, to send the email, it is one command:

mail('youraddress@domain.com', 'Subject', 'Payload', 'Extra Headers if Needed');

If you create a form in HTML, send it to sendmail.html, or whatever your action is, you can use:

$_POST['field'];

Where field equals the name attribute on the input. Example:

<input name="field">

You can then do:

mail('youraddress@domain.com', 'Subject', $_POST['field'], 'Extra Headers if Needed');

That will email you the contents of $_POST['field'].

于 2012-06-06T14:45:26.940 に答える
2

The absolute easiest way would be to validate the fields with jquery and use a mailto as the form action:

<form action="mailto:me@example.com" />

If you have no experience with PHP this is the fastest solution.

于 2012-06-06T14:47:36.073 に答える