0

I have a PHP script for my contact form, but my host is not compatible with PHP scripts. Is there a way to get this PHP code in an <script>tag?

3
  • 3
    The simple answer of your question is No. Commented Sep 4, 2015 at 23:12
  • if the host server does not run php then quite simply NO. The PHP code would show up exactly as written and would not get executed by the server so wouldbe of no use. Commented Sep 4, 2015 at 23:14
  • What kind of web hosting server doesn't support PHP? It's probably the most common server-side language. What do they support? Commented Sep 4, 2015 at 23:45

5 Answers 5

1

No, there is not. PHP runs on the server, not on the client.

And this is for good reasons. A lot of the things you do with PHP, you wouldn't want to let the client do anyway. For instance loading data from the database - if you gave the client your database password it could get any data from your database.

Some of the things done with PHP could be done in JavaScript instead, but in quite different ways. But not all things could.

If your host does not support PHP, you will either have to live without it or change host.

Sign up to request clarification or add additional context in comments.

Comments

0

If your server is not compatible with PHP how do you plan one running PHP? To answer your question, no.

However you could look into using node.js

check this out http://www.nodemailer.com/

Comments

0

No you can't, because PHP is a server-side language, so if your server doesn't support PHP you can't do anything: tags are for client-side languages, such as Javascript, so in this case are useless. What languages does your server support?

Comments

0

No. If the PHP software itself isn't installed on the server, it isn't available to you to run from any scripts as it is server-side code and has nothing to do with the browser (client-side).

However, if PHP was installed on the server, you can run PHP code within <script> tags as follows:

<script language="php">
  // Your PHP code
</script>

(But that isn't good practice)

1 Comment

is there than an good way to use an contact form but with just HTML? I tought that you need PHP to acces mailservers.
0

It's not a good practice to use server side scripts on the front end, better use client side scripts, say javascript. Server side scripting should be used to serve and consume data, to clean user submitted data mainly.

Please make you a favor and enter javascript . There are many good modern frameworks like ANGULARJS and REACTJS, just to mention my preferred.

Having said that, I answer your question, no it's not possible, but your hosting should support any server, so better ask what server scripting does it provide, because it must. The majority of web hostings provide PHP as default.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.