Entering HTML form data to database using SQL? - php

Is it possible to enter HTML form data into a database with SQL without using a PHP script?

It is possible to do it without using a PHP script, but not without using some kind of server-sided script. if your database is stored on a server. It doesn't have to be PHP, it just needs to be something that can take your form data and pass it to the database. Or if your database is stored on your client PC, you could do it there I guess.

No you can't (so far my knowledge goes, i never heard of it anyway) plus you might get into big security problems as you have no control of injection attaks. Always use a server language of any kind (php, asp, python, java or similar) and validate all data before it gets pushed to the database. anyway you can pull data directly with html/xml (old fashined way) but still i think of leaks! my advice to begin with would be a framework what does the job for you in a secure/ save way like laravel, symfony, yii2 or doctrine. there is very much example code and your learning curve for php might be easier thank plain php.
here's the link to the old fashion way of getting data without php but not sending it to the db directly:
https://smallbusiness.chron.com/insert-form-mysql-51070.html

Related

Asp + vXML dynamic data

I have been put in charge of building an IVR using vXML and asp.net. For some reason the voice server we are using requires ASP.net and cannot use PHP in conjunction with vXML so I am stuck learning ASP.net. The application is pretty simple in that it runs an ASP.net file with vXML and should pull data from a database based on user input.
Example:
User enters customer ID "23313"
It should then pull data from our SQL2012 DB that corresponds to that ID and read it back via prompts. Simple enough I figured.
A have a couple questions regarding possible solutions to this -
Is it possible for ASP/vXML to pull data from PHP dynamically (post or get statements), and use the data in the current vXML document? or will I have to bite the bullet and figure out a second page?
if using PHP is not ideal or possible, would it be better or possible to add a db connection into the asp/vXML document and run the IVR that way?
I am not very familiar with ASP.net, and am trying to find out the most efficient way to accomplish my goal without having to have an additional vXML page to run.
Any help appreciated.
EDIT
After further investigation and help from Jim I was able to get inline PHP working. The server I was using was set to go specifically to this asp.net and did not have PHP installed on the server itself. After installing PHP, changing where the server was looking for the file, I am able to run the latest PHP version in my app.
Deleted code sample as it was completely irrelevant
The ASP requirement seems odd, unless you are leveraging some type of library within the ASP.net environment. VoiceXML browsers, are just that, a browser. It should be able to process VXML from the standard sources. I suspect you are working within a framework that requires the serverside ASP.
If your browser is VoiceXML 2.1 compliant, you should have access to the Data element. This element allows you to make Get and Post requests to a server, get back XML and parse the data within Javascript. Note, the return data must be valid XML.
Any database connection would have to be on the ASP.net side of the solution. VoiceXML gets data by transitioning to a new page (goto or subdialog element) or the Data element above.

Accesing php web service and MySQL from Qt/C++ in android. How to send data to service?

I am pretty new with this. I am trying to develop some android application in Qt/Qml to query and update data to a database.
The problem I'm trying to solve:
There is a server with a MySQL database. The android application request some data. I use a very very basic php file that query in the database, format an XML and show that file starting with a header('Content-type: text/xml'); sentence, then some echo "<...>" sentences. This php file receives parameters via $_GET array and performs the query.
This is a little archaic but works fine. My client application use Qt/QML for android. It uses XmlListModel to obtain the data from the server and show that data in a ListView.
So far so good, but here is my real problem:
The user of the android application can change some data, and the modified data must be sent back to the server, who performs an update in the database.
My first attempt was to create another php file and send the data in the URI, get it via $_GET and perform the update to the database. This works but there could be many variables and the URI will become very large. I think might be better to send an XML (or JSON) from the client to the server, and put in that file the data for the update.
So, this is the question: How can I send an XML file from Qt/QML to the server? How does the php file obtain that data? Or maybe there is another, better way for doing this.
Every example I find just shows the server-to-client part, or is written in Java, and I don't know java enough.
Additional notes:
After I can solve this I will fight with security: SSL, avoiding SQL injection or anything, but that will be in another question if necessary.
I didn't use SOAP or similar because the first ideas was simple. Also, I have never used SOAP before. If this is the right way, I would be very grateful if you show me how to use it from Qt/QML in android.
Of course, I can use C++ for the client application since it is using Qt.
I use Qt since I already know it and the app might be useful in desktop as well.
Sorry if I made any english mistake.
Thank you in advance.

Connecting Actionscript 3.0 and PHP?

I have created this drag and drop application using Actionscript, and would like to send variables from here to a MySQL database. But before that, I intend to store the variables as session variables.
I'm not really sure on how to go about doing this and I haven't found anything much online that is relevant. Could someone show me how the PHP and Actionscript side code looks like?
Thank you very much in advance!
No-one here is going to write all that code for you.
The simple stages would be like this;
Have a PHP file for each service (maybe called "writeVariable" and another called "readVariable"). Decide on some way to pass information to and from them - maybe using JSON or XML, or just plaintext. The services would then write and read the data from the database as needed.
Then access those pages from flash through URLLoader and the protocol you set up.

Is it safe to use a MySQL database for recording positions on a multiplayer game?

Would it be safe to use a MySQL database to record positions of players on the screen?
Then everyone second, Flash retrieves the new position data in the database and sets the players' positions of the map to the new positions?
I'm not sure how slow this would be.
I know PHP.
I know SQL.
I am not very experienced in ActionScript, but I can do basic things like set positions of objects.
I do not know how to retrieve information from a database via Flash.
I do not know how to make Flash send out queries.
Do you think you could give me a bit of help?
It would be safe to use MySQL.
But, I strongly wouldn't recommend using PHP + MySQL as a game server though, or your server will tend to lock up from the influx of requests. The HTTP protocol was not designed for this.
It might take a bit of time, but I would learn an easy programming language (especially something like Java or C#) to create a basic server. Then you can store their user information within RAM, instead of constantly accessing the database repeatedly. But, you could also have it where the server updates a database every n amount of minutes, in case the server is shutdown and needs to be started back up with the same data.
Look up 'Flash Remoting' for flash<->server communications. An open-source server-side handler for that is AMFPHP. Flash would send out AMF messages, AMFPHP translates that back into normal PHP data structures, and then you'd have the PHP code handle interfacing to the database.
you would have php be a controller between your db and flash. So flash would send/receive info from php and php would query db.
Yeah, MySQL is pretty secure, as long as you strip all tags, mysql injection etc from the string. And it should be pretty instant.
However, hundreds of MySQL requests every second will be a lot of bandwidth, although I can't think of any alternatives.

Android remote MySQL operations using a web service with php

I read some nice articles about how to connect to a remote MySQL database via Android.
Found some really interesting links here and here.
So the common way for getting data seems to be using some kind of webservice (interface, in this case a php script) which queries the db and renders the result in JSON (or XML) format. Then its possible to parse this output with the android JSON_Object implementation. So far so good.
Receiving data from the database and showing it up in a android listview was done in about minutes.
But what is the best practice for writing (inserting) data into tables?
Should a webservice be used here too? (or rather direct mysql conn)
What is the best method to push data to a webservice? (for ex. to insert a new entity in a database) and which format should be used?
In this case I do not use any html forms or anything to post the parameters. So how to post these parameters to the php script? (from within the android app!)
Of course this operation should be secure as well. Implementing a data manipulation machanism is bit more risky (in order to keep the db persistant)
I think, that many apps use some kind of DB, to synchronize data (ex: highscores).
So there should be a best practise for that.
I would recommend keeping anything database-specific hidden behind a web service.
If you build a dependency on MySQL into your application and later find that you need to change databases, the entire installed base has to be cut over. Think about the logistics of accomplishing that for a few minutes and you'll start to realize it's a nightmare.
Premiumsoft's Navicat for MySQL comes with a HTTP tunnel (PHP script) you might be able to use. It basically provides a method for doing anything to a MySQL database over HTTP.
I'd just make sure there are no licensing issues if you plan to distribute your app.

Categories