Pass variable between two different html file [closed] - php

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
This question may be common question. But this is my exact problem. I am not going to write my code, but explain the scenario.
I have 2 html files to get value from user and 1 php file to process request from 2 html files through XHR.
first html file have person information (like name and email etc..) and following to second html to start another input data.
I save this information in the text file using person name. I could create text file using XHR request to php from first html.
How do I take the filename again which i created in the person name to store the data from second html.
I could not store the filename in any variable because each XHR return is happening individually. So I can't pass choose the filename.
Any idea how do i tackle this?

I would use PHP session mechanism with session_start(); and save variable on session like this $_SESSION['file_name']=fileName; take closer look here PHP tutorial

As said by Marc B, there are no variables in HTML, or a way to store variables and transfer them to another HTML page. You can only use cookies to store and transfer data from one HTML page to the other. Cookies can be handled with PHP Sessions.
You can check a small tutorial on how to create cookies Here.

Related

Is it possible to edit a php file from itself? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to edit a php file from itself? I would like to have a php file that a user can log into with their e-mail address and password then give them a several fields they can edit. Upon submitting their entries the actual php file they used to submit info is updated.
Lets say there are three fields displayed once logged in...
1. Email (can not be read when rendered in a browser or via source code)
2. Password (can not be read when rendered in a browser or via source code)
3. Textarea (contents you submit in the textarea would be visible if you load page in browser, in addtion, a blank username and password field would be visible in a browser, so the owner could login to edit the file)
With this system the user would be able to edit their login information and change information displayed on the page when viewed through a browser. Using the email in the file I guess I could include a sendmail function should they forget their password.
Is this possible. If so, does anyone know of a simple script that I can use to get started?
You are are better off storing the information you want to change in another PHP file. Then loading/editing it on request.
Editing the file you are using can cause issues. You could also loose all of your code if something is injected that corrupts the formatting code.

how to get database data from a web page using PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
In this case i want to extract data from this URL:
https://www.aeropuertosgap.com.mx/es/index.php?option=com_infovuelo&Itemid=746
I did use HTML_DOM but it (obviously) only extracts html data, it is just flight information!
You can't really access another person's database directly unless the airline provide some sort of API to help you access it.
The only real way I think you could do this is if you POST data to the form and then filter through the HTML and get the required data.
See How to set POST data to URL and get results in string variable
From looking at the HTML of the webpage, I can see the form is posted to: index.php?option=com_infovuelo&Itemid=746 and the results are under the div with id "info-vuelo-result".
Good Luck!
P.S. This is one weird question!
Agree with Yahya Uddin. You need to write robot, sending form data, then parse the response, using DOM queries.
Is this a theory question or you want us to develop the code for you?
IF THIS IS A THEORY QUESTION:
well I did something like this with a calendar where the provider did not have any API or anything else, so what I did was get the content with file_get_contents and using preg_match and preg_replace I achieved what I wanted to do with it.
Also check CURL.

Separate php logic from html document and maintain functionality [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm having a bit of trouble wrapping my head around this problem.
I have an image map that I can click which sends various GET requests to my PHP script. My PHP script receives these GET requests and search through my MySQL Database to retrieve the appropriate information. My client is re-directed to this PHP page.
This all works and is great, but I need to incorporate Jquery for other functionality. So, I can't use a standalone PHP script.
My solution to this is use my imagemap to open up a HTML file instead, and use an include statement to incorporate my current PHP file.
However, I don't know how to include the PHP file if I need the GET requests created by clicking the image map.
How can I click on my image map, and be re-routed to a HTML page that displays the same information available from the GET requests in my PHP? I want to do this without creating multiple html files for such a small difference of one variable.
should try to use ajax-javascript to combine the php request with the javascript request and then redirect using the combined info.

What is the correct way of doing JQuery/AJAX and php, file structure? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
what way should I structure my files when doing Jquery AJAX requests in PHP.
i.e.
showRecords.htm - contains jQuery/AJAX that gets data (HTML) from the php file below.
showRecords.php - contains php that does some processing, likely to get data from DB and echo some HTML.
or
one file:
showRecords.php - contains the JQuery/AJAX and is the php file and requests data from itself.
also you clever people out there, please note I am a beginner in JQuery
and AJAX so please forgive me if its a silly question or trivial.
Obviously not: one file.
I'd do it this way:
showRecords.php - form processing, db requests
templates/showSomeHtml.php - displays everything that your users can see
showRecords.js - jQuery/AJAX that gets data
And if the jQuery/Ajax modifies the HTML, you could also move that (the dynamic HTML) into the templates (read about javascript templates)
I think it's up to you. If you have a quick ajax call you'd like to do and you know it won't be used anywhere but there then I see no issue with having everything in one file. On the other hand, you might need to access that processing script in multiple locations on your site. If that's the case, it's not ideal to place it all in one file. I think two files avoids confusion. Keeps everything separate and neat.

Pulling info from an external page [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Okay, bear with me. Part of my job is filling out online forms for customers who call in. In these forms there are all kinds of useful information that is hidden in input tags. I would like to make my own page that would extract and display all this useful information. I would also use this page to count the number of times I submit the form throughout the day.
The way I currently have it set up it is in a frameset. The left frame has links to the different forms we fill out, and when I click on one the external form is populated in the right frame. Javascript would be perfect for the job except that my frame is not located on the same server as the forms.
I stink at PHP. Not gonna lie. So i'm not looking for any hand-outs but any pointers would be great.
For example you may check out the forms on http://www.youcangetacar.com and you may use the pin code "A101" or you can check out what I have so far at http://customertrack.host-ed.me/
Make a page that cURL’s the page that is passed to it via url(curl.php?url=http://www.google.com) and then you dont have trouble with same domain policy.
Don’t forget to string replace relative urls with absolute urls.
eg, action="/submit/form.php" must become action="http://www.domain.com/submit/form.php"

Categories