How can I run a PHP file from Within Visual basic

I have a VB6 Application  and a PHP application on 2 different PCs

I want to take a PHP script  (attached) and run it within the Visual Basic Code

My first thought was that since the PHP Script feels like an HTML  file

there may be a  way  to run it with the Shell command

Can any one help out with this

I attach the PHP Script

Thanks

O.A.  Oluwole
index.php
OlukaySystems AnalystAsked:
Who is Participating?
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
To expand on Julian's answer.

You can easily hand off any file to it's processor - php/perl/python/bash - have each interpreter run the code + return data via STDOUT/STDERR.

And as Julian also said, the problem occurs when you're trying to manage sessions, as your code does.

To accomplish what you're trying to accomplish, you have to reverse your logic.

You'd likely run a LAMP Stack + then call Visual Basic to perform some functions, from your LAMP Stack, so your session is maintained correctly.

And, unless you've written this type of code repeatedly, there are many subtle problems you'll requiring handling.

Likely you'll save yourself a huge amount of time using WordPress + writing your code as a WordPress (PHP) plugin.

This will also mean your code will run anywhere.

If you use Visual Basic, you're stuck with a Windows runtime environment or trying to use one of the public domain interpreters which attempts to correctly parse + execute Visual Basic.
0
 
zephyr_hex (Megan)DeveloperCommented:
Both PHP and VB are server side scripting languages.  You can't "run" a PHP file from VB.  You could convert the PHP code to VB.  Or, call the webpage that the PHP renders from VB (so that the server runs the PHP code and outputs the web page).  So, for example, launch/open http://localhost/index.php from VB

Which approach you take depends on your ultimate goal.  If you just want to display index.php, you can simply open the webpage like any other website from VB.  If you want to get results, etc that the PHP code provides and do something with them in VB, you'll need to convert the code to VB.
0
 
Ryan ChongCommented:
Both PHP and VB are server side scripting languages.

this is somehow not true since VB6 Application is not really categorized as server side scripting languages.

To enable VB6 Application to call a html or php page, you can try:

VBA Web Requests
https://coderwall.com/p/pbxsyw/vba-web-requests
0
 
Julian HansenCommented:
A bit of misinformation going around.

PHP is a scripting language in its own right - which means if you have a PHP interpreter installed on your computer you can run a php script at the commend line like so
Script: test.php
<?php
echo "Hello World";

Open in new window

Command
> php test.php

Open in new window

And you will get
Hello World

Open in new window

However in this case the php file provided is a web page - which means its output is going to be HTML most likely intended for a browser.

The script in question - the first thing it does is throw you to a login page because you are not logged in - so already you have a speed bump right there. For this page to do anything it
a) Needs access to a server SESSION - which you won't have when you run the file locally
b) That session needs to be primed with an empno value that will allow you to continue

So the question is really - what are you hoping to achieve here? What is it you actually want to do - because I don't think you are going to get the answer you want based on the information you have given us so far.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.