Jump to content

Recommended Posts

Hello,

 

I have got this example from my vendor for Axigen mailing server.

They gave PHP files to call the server for some operations, but by server runs on Dot.Net

Now, can any one pls help me how to rewrite the below code to work like a function......

 

I want to call the php file as a function in my dot net asp programing. Or any other way which will bridge the gap from ASP.Net to PHP.

 

 

 

 

<?php
require_once("Axigen.php");

# Configuration:
$axigen_host = "1.0.0.1";
$axigen_port = 5000;
$axigen_user = "admin";
$axigen_pass = "admin_password_here";

$axigen_primary_domain = "domain_name_here";

# End of configuration

if($_REQUEST['username'] and $_REQUEST['password']) {

$username = $_REQUEST['username'];
$password = $_REQUEST['password'];

$session = new Axigen();
$session->connect($axigen_host, $axigen_port, $axigen_user, $axigen_pass);

$domain_object = $session->updateDomain($axigen_primary_domain);
if(!$domain_object) {
	echo "Error entering context for domain '$axigen_primary_domain'.";
	exit;
}
$account_object = $domain_object->addAccount($username, $password);
if(!$account_object) {
	echo "Error creating account '$username'.";
	exit;
}
echo "Account '$username@$axigen_primary_domain' created.";

}
else
{
echo "Create account in domain '$axigen_primary_domain': <br />
	<form method=post>
		Username: <input type='text' name='username'><br />
		Password: <input type='password' name='password'><br />
		<input type=submit value='create user'>
	</form>
	";
}

Hello, I had another Idea,

 

Is it possible to create a PHP file that works as a Web Service?

 

This is what happens......

 

1)  I will call the Target PHP File from my ASP.Net file with Parameters in Post Method of a Form

2)  The Target PHP file will have no display or UI, but will simply process the content to create an account or to end up with an error message if the account already exists,

3)  Returns the String value to the Calling Method of the ASP.Net page with the result (either OK, or Error Desc)

4)  Basing on the answer, the rest of the ASP.Net page continues.

 

Please let me know if this is atleast possible.....

 

Thanks and regards.

 

Jagat.

 

Yes

 

If your using HTTP POST access the data using $_POST

So as an example your asp file will post 4 bits of data and the php will add a user to the database

 

if($_POST['action'] && $_POST['action'] == 'createacct') {
  $username = mysql_real_escape_string($_POST['username']);
  $password = mysql_real_escape_string($_POST['password']);
  $name = mysql_real_escape_string($_POST['name']);

  // connect to database and insert the new user
  $x = mysql_connect();
  mysql_select_db();
  mysql_query("INSERT INTO users.......

}

get the idea

 

your form names / values

action | createacct

username

password

name

 

Hello,

 

Can we achieve this using some simple REST web services for PHP.

 

I am totally new to PHP and REST, i'm just looking into these.

 

Can anyone please let me know how to work with this, if this is incorporated as Webservices, i can simply call from any project in any language. Ofcourse currently we use Dot.Net.

 

I just want to pass 2 variables and get a result.

 

The main Reason is that I cant navigate away from the page which is calling, i need to work from there and use the function Just Like A function and display the results.

 

Please some one help me.

 

Regards,

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.