December 17th, 2012, 03:12 AM
Html read php variables
I make a simple temrerature.php file into my webserver with $temp="25"; simple variable.How i can display this variable into my intex.html file?I try this
but no work....My site support php.
<td><input type="text" size="4" value="<?temperature.php echo $temp; ?>"/></td>
December 17th, 2012, 03:16 AM
you forgot the name=" " attribute btw
Also notice the php tags (if temperature.php is a different file you need to [PHPNET="include"]include[/PHPNET] it)
<input type="text" name="somefield" value="<?php echo $temp; ?>" />
Last edited by aeternus; December 17th, 2012 at 03:19 AM.
December 17th, 2012, 03:27 AM
I try it but no work...i try and this...
...but no work...For save data work...i use this
Temperature is: <?temperature.php echo $_GET["temp"]; ?>.<br>
.Where is my mistake?
<form name="delay" method="post" action="delay.php"> Input delay time seconds: <input type="text" name="sec" value="" size="4" maxlength="4">
December 17th, 2012, 04:01 AM
Did you read the link??
Originally Posted by antkan
this is wrong (already mentioned it):
should be <?php
December 17th, 2012, 04:34 AM
I test this...inside my html index.html
<td><input type="text" name="somefield" size="4" value="<?php include 'temp.php'; echo $temp; ?>"/></td>
but no work....
December 17th, 2012, 04:49 AM
(if you are testing place this above all your scripts)
Make sure in your case that the 2 files are in the same directory
Btw it is probably a better Idea to include the file at the top of your script to keep it more organized
Last edited by aeternus; December 17th, 2012 at 04:55 AM.
December 17th, 2012, 06:03 AM
I try this code....
but no display anything...
<html> <head> <title>Untitled</title> </head> <body> <?php ini_set('display_errors',1); error_reporting(E_ALL); echo "hello"; ?> </body> </html>
Host optios are...
Php support is on,
Allow web users to use scripts is on but
Apache ASP support is off....
when load mysite/temp.php
with this code
display data 23
<?php $temp = "23"; echo $temp; ?>
December 17th, 2012, 06:13 AM
OK lets start with the basics. Skipp your code and do the following nothing more nothing les.
Make a file in notepad and call it test.php Put in that code the following. Upload it and run it.
Does that work? Do you have a book or something about php?
echo 'hello world';
$variable = 'this is a variable';
December 17th, 2012, 06:23 AM
Yes work and print hello worldthis is a variable but i want to display my variable from php file to index.html
December 17th, 2012, 06:26 AM
EXACTLY!~ but you can't because the file should be named .php for your server to process it as php. (unless you mess around with some server settings which i recommend you don't)
Originally Posted by antkan
So rename all files you have that you would like to include php in to .php (so with a .php extension instead of a .html one)
You might want to get a decent book instead of online tutorials. books tend to start at the beginning .
Last edited by aeternus; December 17th, 2012 at 06:29 AM.
December 17th, 2012, 06:31 AM
Ok.I understand i must make index.php.I want to make an apk to my android to upload a simple variable temperature....and read from client.It is possible for auto refresh if receive web server the data?Any advise?What type file must upload for my variable temperature .php .txt?