Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.20/5 (2 votes)
See more:
I'm building a simple application that requires login. At the moment I'm connecting to my database directly from my C# application however, the college network on which this will be used doesn't allow direct connections to MySQL for some reason. I decided to take a look at how I would do this from PHP instead. I've build a simple login form and tested it and it seems to work. However I have some questions and issues that need sorting out.

How would I first of all stop just anyone typing in the address of the PHP file and getting the data back?

Second, how will I be able to get multiple results back? Let's say I make a PHP file that gets all of the user's files and stores them in the C# application, how do I actually parse this from the PHP file?

Sorry if this question is a bit confusing, I basically just need to know how to correctly manipulate a database with PHP using C# with correct security in place.
Posted
Comments
Sergey Alexandrovich Kryukov 7-May-14 11:38am    
Work with PHP in C#? What is that supposed to mean? Where do you want to use C# in this case, on server side or client side?
Could you use ASP.NET?
"How would I first of all stop just anyone typing in the address of the PHP file and getting the data back?" is completely unclear.
It all gives strong impression that you have no idea what you are asking about. (How about learning how Web works in principle? It's very simple, in essence.) I'll be very glad if you prove me wrong.
—SA

1 solution

Let's assume that you have a constraint in your application architecture that really need to be like you describe.

1. How can you secure the php address file that gets the data?

You will need to create authentication and authorization mechanisms in your php solution.

2. Parse the php file from C#

PHP generates a html file in the end, so you need to parse HTML and not PHP.
There are a great library for parsing HTML which is HtmlAgilityPack.

JAFC
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900