在C#中使用PHP和MySQL的最佳方法是什么? [英] What is the best way to work with PHP and MySQL in C#

查看:74
本文介绍了在C#中使用PHP和MySQL的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个需要登录的简单应用程序。目前我正在从我的C#应用​​程序直接连接到我的数据库,然而,将使用它的学院网络由于某种原因不允许直接连接到MySQL。我决定看看我将如何从PHP中做到这一点。我已经构建了一个简单的登录表单并对其进行了测试,它似乎可行。但是我有一些问题需要整理出来。



我怎么能首先阻止任何人输入PHP文件的地址并获取数据?



其次,我怎样才能获得多个结果?假设我创建一个PHP文件来获取所有用户的文件并将它们存储在C#应用程序中,我如何从PHP文件中实际解析它?



对不起如果这个问题有点令人困惑,我基本上只需要知道如何使用C#正确操作数据库,并使用正确的安全性。

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.

推荐答案

让我们假设你的应用程序架构中有一个限制,真的需要像你描述的那样。



1。如何保护获取数据的php地址文件?



您需要在php解决方案中创建身份验证和授权机制。



2。从C#解析php文件



PHP最终生成一个html文件,因此你需要解析HTML而不是PHP。

有一个很好的解析HTML的库,它是 HtmlAgilityPack



JAFC
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


这篇关于在C#中使用PHP和MySQL的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆