473,788 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to share/use a variable between PHP and HTML on the same page ?

How to share/use a variable between PHP and HTML on the same page ?
( i.e. without using GET/ POST etc.... )

Is it possible ?

And what about same with PHP and JavaScript ?
Nov 19 '07 #1
2 2280

On Nov 19, 8:40 am, pradnya <pdu...@gmail.c omwrote:
How to share/use a variable between PHP and HTML on the same page ?
( i.e. without using GET/ POST etc.... )

Is it possible ?

And what about same with PHP and JavaScript ?
You can share through from PHP to HTML just one way (server->client)
through a hidden input field
Example:
<INPUT TYPE="hidden" NAME="htmlvar" value=<?php echo $phpvar ?/>
For Javascript it is then possible to access it.

For two way communication you should really look into AJAX/ JSON
principles
Nov 19 '07 #2
pradnya wrote:
How to share/use a variable between PHP and HTML on the same page ?
( i.e. without using GET/ POST etc.... )

Is it possible ?
Not sure what you mean. HTML doesn't have "variables" .
And what about same with PHP and JavaScript ?
Depending on what you want to achieve there are several techniques. You
can use PHP to generate the Javascript in the first place, which allows
PHP to populate the script's variables with certain values. Or a piece of
Javascript can communicate with a PHP script using AJAX.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 12 days, 15:35.]

USD/EUR Exchange Rate Graph
http://tobyinkster.co.uk/blog/2007/11/18/usd-eur/
Nov 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
8562
by: Ikke | last post by:
I have to share a variable between browser sessions. One session for example changes the variable, the other sessions must see the changes (get the new value instead of the original value) it's not allowed to save the value in a database or to save it into a file. It must be a kind of global server variable, changeable by every session. tia
0
4616
by: S Johnson | last post by:
>Trying to start first time using command: > C:\mysql\bin\mysqld --standalone > > Yields this error message: Can't find > messagefile'C:mysqin\share\english\errmsg.sys' aborting > > Now in C:\mysql\share\english\ there is an errmsg.sys Do you have any language=C:/mysqin/share/english/ entry in the my.ini?
2
2537
by: Robizzle | last post by:
I've been working on some php scripts that I want to release under the GPL and I'm looking for the best way to share the code with everyone. I always liked websites that had a <textfield> and put the source into the field, it allowed for easy copy and pasting as well as the ability to read the code without having to download a file, save it somewhere, then open it up, and lastly it preserves formatting. So on my page that shows source I...
2
1413
by: VB Programmer | last post by:
I've read that you can save a session state variable created by an ASP page into a db so that the value of the session state variable can be read/used by an ASP.NET webform. Question: Let's say the session variable is called "UserIsAdmin" and the ASP page is the login page. When the person logs in as 'admin' it stores the session variable as "True" in a db. How does the ASP.NET page that is served up know whether the page requestor is...
8
4556
by: Tony Fonager | last post by:
I am currently developing a statistics system in ASP.NET, and need to share information about the customers websites, in this application. (I have simplified my code, to make my project easier to explain.) The simple version of the system is like this : A customer inserts HTML code on his webpage, which contacts my statistics server each time the customers website recieves a hit - like a classic "register website traffic" system. ...
3
1397
by: far asl via DotNetMonster.com | last post by:
I have developed my site admin pages some in asp while others are in asp.net. I have problem that i cannot share session variables of both alternatively. Actually i save my userid in session variable.Index page is in asp.After login page a details page is in asp.net. Now thsi details page can be accessed directly through url. I WANT TO USE THE SESSION VARIABLE CREATED IN INDEX.ASP IN ASP.NET. MESSAGE POSTEDBY: FARHAD
8
7529
by: zdp | last post by:
Hello! I need to process some webpages of a forum which is powered by discuz!. When I login, there are some options about how long to keep the cookies: forever, month, week, et al. If I choose forever, I don't need to login each time, and When I open the internet explorer I can access any pages directly. Some urls of the pages like: http://www.somesite.com/bbs/viewthread.php?tid=12345&extra=page%3D1
6
2180
by: Immortal Nephi | last post by:
First class is the base class. It has two data: m_Base1 and m_Base2. Second class and third class are derived classes and they are derived from first class. m_Base1 and m_Base2 are inherited into two derived classes. Second class has its own m_Base1 and m_Base2 and third class does the same. I am curious. How can second class and third class share the same m_Base1 and m_Base2? You define second class first and enter data into...
3
2762
by: rajkpy | last post by:
Hi Experts, I have created a login page in php called login.php, it accepts username, password and domain and then does some authentication. IF authentication succeeds it starts a php session and sets a session attribute. In my php application, i check this session attribute in all the pages to find out whether the user has logged in or not. Now I have another application entirely written in html. Now I want to call this login.php page when...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8995
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5402
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2896
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.