Passing Form Data to PHP

Hello,

I am a total newbie. I am trying to use an API for which I have an example. I can get what I need by hardcoding the PHP file with variable information (i.e. name, email address, etc) and everything works. I want to be able to create a form that will pass information to the PHP program so that I do not have to hard code.

Here is what the hard coding looks like:

[size=10pt]<?php
$livezillaURL = “http(s)://{yourdomain}/livezilla/”;
$apiURL = “http://abc.com/api/v2/api.php”;

// authentication parameters
$postd[“p_user”]=‘myuserid’;
$postd[“p_pass”]=md5(‘mypassword’);

// function parameter
$postd[“p_abc_create”]=1;
$postd[“p_json_pretty”]=1;

class ABC
{
public $Email = "[email protected]";
public $Company = “Doe Ltd.”;
public $Firstname = “John”;
public $Lastname = “Doe”;
}

$newItem = new ABC();
$postd[“p_data”]= json_encode(array(“ABC”=>$newItem));

etc…

?>[/size]

All I am trying to do is create an HTML form where I can pass the email address without hard coding.

Please help!

What does the form look like? Keep in mind that PHP can only access fields that have a name property.

Thanks so much for your reply!

The form would simple HTML like:

Name:
E-mail:

api.php is the 3rd party API and my .php file would as per my code sample.

First off, are you saying that I need an input field name “name”?

Sorry for the dumb questions.

No, it would be a name attribute.

You should also process and validate the form before you send it to their API.

Then you probably want this in your form,

[php][/php]

And you would get the value passed with:

[php]$_POST[‘email’][/php]

Does the api not use their own data- attributes for information?

I will definitely put form validation in once I get past this hurdle…

I’m trying to use the livezilla API (http://www.livezilla.net/apiv2/en/?api_section=general)

I guess it does have it’s own data attributes.

The specific example I’m trying to work is at: http://www.livezilla.net/apiv2/en/?api_section=examples under the sections: PHP code to create an operator account or a chat voucher.

Thanks.

What are you trying to do? If you need the work done with less of a headache, send me a PM. The API looks to do several things, so you need to narrow down what services you are wanting.

Sponsor our Newsletter | Privacy Policy | Terms of Service