hey looking for some assistance with a little PHP
have zero experience in php but i have been playing
about trying some thing for past 20min
im trying to create a form page to collect users information
a user fills in the information on my site which use that information
to create an account on another site as well as storing the information
on my site
how would i get this to post the content to the api url but also post the same content to my own mysql database or sugarcrm as well as having
the information sent to aweber or simlar for opt-in
:breakpc1:
have zero experience in php but i have been playing
about trying some thing for past 20min
im trying to create a form page to collect users information
a user fills in the information on my site which use that information
to create an account on another site as well as storing the information
on my site
Code:
<?php
$API_URL = "http://randomcpaoffer.com";
function rest_helper($url, $params = null, $verb = 'GET', $format = 'json') {
$cparams = array(
'http' => array(
'method' => $verb,
'ignore_errors' => true
)
);
if ($params !== null) {
$params = http_build_query($params);
if ($verb == 'POST') {
$cparams['http']['content'] = $params;
} else {
$url .= '?' . $params;
}
}
$context = stream_context_create($cparams);
$fp = fopen($url, 'rb', false, $context);
if (!$fp) {
$res = false;
} else {
$res = stream_get_contents($fp);
}
if ($res === false) {
throw new Exception("$verb $url failed: $php_errormsg");
}
switch ($format) {
case 'json':
$r = json_decode($res);
if ($r === null) {
throw new Exception("failed to decode $res as json");
}
return $r;
case 'xml':
$r = simplexml_load_string($res);
if ($r === null) {
throw new Exception("failed to decode $res as xml");
}
return $r;
}
return $res;
}
if (isset($_POST['firstname'])) {
$res = rest_helper($API_URL,
array(
'track' => $_POST['track'],
'First Name' => $_POST['firstname'],
'Last name' => $_POST['lastname'],
'email' => $_POST['email']
'ip' => $_POST['ip'],
), 'POST');
if ($res->result == "success") {
header("Location: {$res->login*****");
exit();
}
}
?>
<?
if ($res->error_list) {
print "Please correct the following errors:<br>";
foreach ($res->error_list as $api) {
print "$api<br>";
}
}
?>
<form method='post'>
<input type='hidden' name='track' value='default'>
<h3>Sign Up</h3>
First Name: <input type='text' name='firstname' value='johnsmith'><br>
Last Name: <input type='text' name='password' value='jsmith'><br>
Email Address: <input type='text' name='password' value='[email protected]'><br>
<br>
IP: <input type='text' name='ip' value='111.111.111.111'><br>
<br>
<input type='submit'>
</form>
how would i get this to post the content to the api url but also post the same content to my own mysql database or sugarcrm as well as having
the information sent to aweber or simlar for opt-in
:breakpc1: