Page 1 of 1

How to pass a value from php to html?

Posted: Sat Apr 17, 2010 9:27 am
by shishirkotkar
I have a html file - Home.html
I have another php file - test.php

I am calling test.php on click of a submit button from Home.php

in test.php i am processing the input data entered from Home.php

I want to send the processed results back to Home.php and present it as values in dropdown list.

How do i do that?

Re: How to pass a value from php to html?

Posted: Sat Apr 17, 2010 9:55 am
by JAY6390
I would suggest you do this with one page like I show in the following URL
http://www.jaygilford.com/php/how-to-pr ... -one-page/

You can redirect to the page using the header() function and the Location value, but would still need to send the data with it (using something like a session of some sort). You would need to change home.html to home.php to get this to work correctly or use some htaccess rewrites to get it to work with php

Re: How to pass a value from php to html?

Posted: Sat Apr 17, 2010 12:07 pm
by st3fanos
Hi,

First I am going to assume you have home.html and test.php (not home.php) and for some reason you cannot change the name of home.html.

You can do what you want by using the GET method, i.e your URL back to your home.html from test.php would look like http://www.somedomain.com/home.html?var ... var2=World

You can then go ahead and do something like the following using javascript:
http://failchad.blogspot.com/2009/01/ac ... cript.html

But why?
1) If it's a problem that you cannot process the HTML file as PHP code you could use the .htaccess and tell your server to treat the .html as if it were PHP.
or
2) change the filename home.html -> home.php and use mod_rewrite so it looks like home.html (not sure of the top of my head the code)

With all the above methods the end URL looks like home.html, but with the last 2 you can avoid passing the values in the URL.

Hope it helps
Stephen