d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php Submit Data To Multiple Locations
12Next
Add Reply New Topic New Poll
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Aug 27 2013 06:06pm
Friendly, knowledgeable PHP devs of D2JSP,

I come to you with another script I need help completing.


I have a file (template.php) which is fed data from another file (tool.html)
(template.php) is essentially a blank html file, which when fed form data from (tool.html) actually displays information like a normal webpage.

What I need to do is collect the source code from (template.php) after it has been fed the appropriate data from (tool.html)
Afterwards, I then need to submit the collected source code to a specific database table column.
The tricky part is that while submitting the source code of the completed (template.php) file I need to simultaneously submit other data from (tool.html) to other columns in the same database table.

I apologize for any confusion, as I'm sure my scenario is poorly explained. I will elaborate a little...

Basically, what I'm trying to do is create a new row in database table with information from the form in (tool.html).
Most of the data from (tool.html) could be submitted directly to the database, however I need part of the data to first go to (template.php) to complete the source code.
The KEY part is that I need the user to be able to submit ALL of their data at once!

I can "imagine" a couple of ways to do this, but I fear that I might be over thinking this too much.
As always, any help is very much appreciated.

- Grievance
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 27 2013 06:19pm
why are you putting php source code into a database table? if all the real data is in tools.html, why not just save that data? then have another table hold the template.

or do you mean something entirely different when you say source code?
Member
Posts: 237
Joined: Aug 6 2011
Gold: 6,026.00
Aug 27 2013 10:28pm
I do not understand how this task is difficult, even more so in php.

What stopping you from submitting data to your db from both the template file and the client's push from the same php script? Or is the simultaneous part design significant?
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Aug 28 2013 04:30am
im not sure how this is to multiple locations, anyways this is what you do.

on your tools.html make sure your form action is pointing to template.php.

template.php gets all the information, then you do your mysql insert in template.php, then if you need to go back to tool.html, just do a php header(location) or a javascript window.location back to tool.html at the end of the data parsing/mysql query.
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Aug 28 2013 08:02am
Quote (AkuuZ @ Aug 28 2013 04:30am)
im not sure how this is to multiple locations, anyways this is what you do.

on your tools.html make sure your form action is pointing to template.php.

template.php gets all the information, then you do your mysql insert in template.php, then if you need to go back to tool.html, just do a php header(location) or a javascript window.location back to tool.html at the end of the data parsing/mysql query.


Thank you for this suggestion. I will give this a go today.


Quote (flyinggoat @ Aug 27 2013 10:28pm)
I do not understand how this task is difficult, even more so in php.

What stopping you from submitting data to your db from both the template file and the client's push from the same php script? Or is the simultaneous part design significant?


The simultaneous part is design significant. It doesn't have to actually process everything simultaneously, but the end-user for this tool should only have to click submit once.

Quote (carteblanche @ Aug 27 2013 06:19pm)
why are you putting php source code into a database table? if all the real data is in tools.html, why not just save that data? then have another table hold the template.

or do you mean something entirely different when you say source code?


When I say source code I mean HTML & CSS.

Basically, the tool I'm making is to design to simplify a 3rd-party tool that the end-user uses on a daily basis. The tool they use require the end-user to enter some source code themselves, along with a lot of other data. My tool is databased back so that once one my end-user creates an entry and submits it to their tool he/she never has to recreate the same entry. They can just call it up from the database and resubmit it to this other tool. The source code for any given entry is completely useless without the ~29 other columns worth of data.

This post was edited by grievance on Aug 28 2013 08:04am
Member
Posts: 237
Joined: Aug 6 2011
Gold: 6,026.00
Aug 28 2013 12:06pm
I'd suggest using a main script, something like main.php let's say.

Point the form from tool.html to main.php. In there you then open the template.php file, append or just overwrite the content (not sure which one fits your bill), add the data to the db, then redirect to either tool.html or template.php based on what you have to display.
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Aug 28 2013 12:57pm
Quote (flyinggoat @ Aug 28 2013 12:06pm)
I'd suggest using a main script, something like main.php let's say.

Point the form from tool.html to main.php. In there you then open the template.php file, append or just overwrite the content (not sure which one fits your bill), add the data to the db, then redirect to either tool.html or template.php based on what you have to display.


Thank you, very much for this suggestion. I think this one might be a winner.
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Aug 28 2013 03:13pm
are you any good with ajax?
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Aug 29 2013 07:38am
Quote (AkuuZ @ Aug 28 2013 03:13pm)
are you any good with ajax?


No :( Honestly, I know very little about it. I "think" is fits in the same category as PHP / ASP.NET, but I'm not even sure about that.
The only technologies I understand well enough to be comfortable with them are HTML, CSS, PHP, SQL, JavaScript, Batch, and C++ (Still a beginner with C++)

Is ajax a language you would typically recommend to somebody attempting this kind of task? If the similar to anything I know already I could probably learn it fairly quick.
Learning new concepts and syntax has typically been very easy for me, it's memorizing keywords/libraries that is challenging.

This post was edited by grievance on Aug 29 2013 07:40am
Member
Posts: 2,217
Joined: Sep 10 2007
Gold: 35.88
Aug 29 2013 07:44am
Quote (wikipedia)
Ajax (also AJAX; /ˈeɪd’æks/; an acronym for asynchronous JavaScript and XML)[1] is a group of interrelated web development techniques used on the client-side to create asynchronous web applications. With Ajax, web applications can send data to, and retrieve data from, a server asynchronously (in the background) without interfering with the display and behavior of the existing page. Data can be retrieved using the XMLHttpRequest object. Despite the name, the use of XML is not required (JSON is often used instead), and the requests do not need to be asynchronous.[2]
Ajax is not a single technology, but a group of technologies. HTML and CSS can be used in combination to mark up and style information. The DOM is accessed with JavaScript to dynamically display, and allow the user to interact with, the information presented. JavaScript and the XMLHttpRequest object provide a method for exchanging data asynchronously between browser and server to avoid full page reloads.


Heh.. How did I overlook this one? If that wikapedia description is even close it seems like an excellent "new" technology to learn, it also seems like a good choice for what I'm doing.
I also checked out a few AJAX + MySQL examples. It seems like a really excellent direction to head with my project.

Thanks so much for mentioning this one!
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll