Hi, I am new to php and phplot. I am using phplot 5.0 as my provider is only
on php4.something.
I am trying to get a web page that contains a form and a plot from phplot all
on the same page.
I want to be able to
1) enter data into the form
2) press the submit button and
a) have the data values remain in the form
b) have the plot update with the new/modified data
3) be ready to get new/modified data
I have tried using two different php files, one php file, even writting the
image to a file and reading it with tag (the file seems to never get
updated). I would really rather not read/wrtie a file, but have tried many
variations with no luck.
Does anyone have an idea how this might be done, or may have already done this
type of web page?
Thanks in advance for any help you can give.
Steve T.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am using phplot 5.0 as my provider is only on php4.something.
That's sad. It has been 2 years since PHP 4 support was discontinued.
I am trying to get a web page that contains a form and a plot from phplot
all on the same page.
Here is the basic idea. There are certainly other ways.
For your web page with form and image, you need 2 PHP scripts. Call them
form.php and image.php just for discussion. form.php is the main script that
the browser references by URL. The script needs to check for form parameters.
If there are no form parameters, depending on what you are doing, you may want
to display a default plot or no plot at all.
If there are form parameters, they are used to populate default values for the
form, and to display the plot.
To display the plot, the form.php script sends an IMG tag to the browser in
the page it produces. The URL in the IMG tag points to your second script,
image.php. You also need to send parameters (from the form submission or
defaults) to the image.php script, to tell it how to draw the plot. You can do
this with URL parameters, with appropriate escaping. (You can use session
variables instead, which is most useful if you are already doing sessions.) So
image.php might contain something like this:
Which passes 2 parameters, values assumed to already be escaped with
urlencode(). When the browser processes the returned page from form.php, it
will make a second request to image.php for the image.
The image.php script checks and validates its GET parameters (or session
variables, if you are doing it that way), and uses PHPlot to produce the
image. Note that if image.php gets an error, it must not just output an error
message in HTML, because the browser is expecting an image.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I am new to php and phplot. I am using phplot 5.0 as my provider is only
on php4.something.
I am trying to get a web page that contains a form and a plot from phplot all
on the same page.
I want to be able to
1) enter data into the form
2) press the submit button and
a) have the data values remain in the form
b) have the plot update with the new/modified data
3) be ready to get new/modified data
I have tried using two different php files, one php file, even writting the
tag (the file seems to never get
image to a file and reading it with
updated). I would really rather not read/wrtie a file, but have tried many
variations with no luck.
Does anyone have an idea how this might be done, or may have already done this
type of web page?
Thanks in advance for any help you can give.
Steve T.
That's sad. It has been 2 years since PHP 4 support was discontinued.
Here is the basic idea. There are certainly other ways.
For your web page with form and image, you need 2 PHP scripts. Call them
form.php and image.php just for discussion. form.php is the main script that
the browser references by URL. The script needs to check for form parameters.
If there are no form parameters, depending on what you are doing, you may want
to display a default plot or no plot at all.
If there are form parameters, they are used to populate default values for the
form, and to display the plot.
To display the plot, the form.php script sends an IMG tag to the browser in
the page it produces. The URL in the IMG tag points to your second script,
image.php. You also need to send parameters (from the form submission or
defaults) to the image.php script, to tell it how to draw the plot. You can do
this with URL parameters, with appropriate escaping. (You can use session
variables instead, which is most useful if you are already doing sessions.) So
image.php might contain something like this:
Which passes 2 parameters, values assumed to already be escaped with
urlencode(). When the browser processes the returned page from form.php, it
will make a second request to image.php for the image.
The image.php script checks and validates its GET parameters (or session
variables, if you are doing it that way), and uses PHPlot to produce the
image. Note that if image.php gets an error, it must not just output an error
message in HTML, because the browser is expecting an image.
Ibayuk, thank you for your quick reply. I was thinking about that approach as
well. I will et you know how it comes out.
It is sad about the php version, it was not on my mind when I got my current
provider. I will start shopping for a new provider.
Thanks, again. Steve T.
Well, I decided to take the opportunity to learn about sessions and session
variables. It solved my problem and all is working well.
Thank you, Steve T.