PDA

View Full Version : PHP Submit


MSP
12-22-2008, 11:34 AM
Hello,
I am trying to incorporate the HTTP.Submit() in AMS to my php site. It basically is a registration page that users fill out prior to receiving the autoplay app. I basically have a registration webpage which posts to a mySQL DB. I need to know how to setup the PHP in order to use the HTTP.Submit in AMS. The page currently has text boxes which the user fills out and clicks a button to submit. I am very novice which it comes to php and need a little help. Any comments are greatly appreciated! Thanks in advance!

MSP

Imagine Programming
12-22-2008, 12:13 PM
just use the POST method in the HTTP.Submit() function and it works as normal

if you have a <input name="blaa"> use in table values: {blaa="what's filled in"}

etc.

I hope this helps you

MSP
12-22-2008, 01:53 PM
I am still having problems and cannot figure it out. Here is my register.php:

<?php require_once('Connections/connMarathon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO dashboard_registration (reg_id, proj_id, first_name, last_name, company, address1, address2, city, `state`, zip, phone, cell_phone, fax, email, discipline, registration_date, ip, distribution_method) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['reg_id'], "int"),
GetSQLValueString($_POST['proj_id'], "int"),
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['last_name'], "text"),
GetSQLValueString($_POST['company'], "text"),
GetSQLValueString($_POST['address1'], "text"),
GetSQLValueString($_POST['address2'], "text"),
GetSQLValueString($_POST['city'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['zip'], "int"),
GetSQLValueString($_POST['phone'], "text"),
GetSQLValueString($_POST['cell_phone'], "text"),
GetSQLValueString($_POST['fax'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['discipline'], "text"),
GetSQLValueString($_POST['registration_date'], "date"),
GetSQLValueString($_POST['ip'], "text"),
GetSQLValueString($_POST['distribution_method'], "text"));

mysql_select_db($database_connMarathon, $connMarathon);
$Result1 = mysql_query($insertSQL, $connMarathon) or die(mysql_error());
}
?>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Reg_id:</td>
<td><input type="text" name="reg_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Proj_id:</td>
<td><input type="text" name="proj_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">First_name:</td>
<td><input type="text" name="first_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last_name:</td>
<td><input type="text" name="last_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Company:</td>
<td><input type="text" name="company" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address1:</td>
<td><input type="text" name="address1" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address2:</td>
<td><input type="text" name="address2" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td><input type="text" name="city" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">State:</td>
<td><input type="text" name="state" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Zip:</td>
<td><input type="text" name="zip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Phone:</td>
<td><input type="text" name="phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cell_phone:</td>
<td><input type="text" name="cell_phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fax:</td>
<td><input type="text" name="fax" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Discipline:</td>
<td><input type="text" name="discipline" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Registration_date:</td>
<td><input type="text" name="registration_date" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Ip:</td>
<td><input type="text" name="ip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Distribution_method:</td>
<td><input type="text" name="distribution_method" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>


This works if you go to the Webpage directly so I think the problem is my HTTP.Submit().

Here is what I have for that.

myvalues = {proj_id="35", first_name="James", last_name="Johnston", company="Marathon", address1="1000 Main", address2="", city="Kansas City", state="MO", zip="64108", phone="", cell_phone="", fax="", email="", discipline="", registration_date="", ip="", distribution_method=""};
result = HTTP.Submit("http://www.mywebsite.com/register.php", myvalues, SUBMITWEB_POST, 20, 80, nil, nil);
I have tried to use SUBMITWEB_GET too with no luck. It acts like is working, but doesn't add it to the DB. The HTTP.Submit() returns the website it finds so I know it is finding it. Thank you for all of your help!

ShadowUK
12-22-2008, 02:42 PM
Try using method GET, And changing $_POST to $_GET.

I've had problems using post in the past in AMS.

MSP
12-22-2008, 03:05 PM
It is still not working properly. I did the replacement of all POST with GET and here is what I have now.
<?php require_once('Connections/connMarathon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET["MM_insert"])) && ($_GET["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO dashboard_registration (reg_id, proj_id, first_name, last_name, company, address1, address2, city, `state`, zip, phone, cell_phone, fax, email, discipline, registration_date, ip, distribution_method) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_GET['reg_id'], "int"),
GetSQLValueString($_GET['proj_id'], "int"),
GetSQLValueString($_GET['first_name'], "text"),
GetSQLValueString($_GET['last_name'], "text"),
GetSQLValueString($_GET['company'], "text"),
GetSQLValueString($_GET['address1'], "text"),
GetSQLValueString($_GET['address2'], "text"),
GetSQLValueString($_GET['city'], "text"),
GetSQLValueString($_GET['state'], "text"),
GetSQLValueString($_GET['zip'], "int"),
GetSQLValueString($_GET['phone'], "text"),
GetSQLValueString($_GET['cell_phone'], "text"),
GetSQLValueString($_GET['fax'], "text"),
GetSQLValueString($_GET['email'], "text"),
GetSQLValueString($_GET['discipline'], "text"),
GetSQLValueString($_GET['registration_date'], "date"),
GetSQLValueString($_GET['ip'], "text"),
GetSQLValueString($_GET['distribution_method'], "text"));

mysql_select_db($database_connMarathon, $connMarathon);
$Result1 = mysql_query($insertSQL, $connMarathon) or die(mysql_error());
}
?>
<form method="GET" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Reg_id:</td>
<td><input type="text" name="reg_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Proj_id:</td>
<td><input type="text" name="proj_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">First_name:</td>
<td><input type="text" name="first_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last_name:</td>
<td><input type="text" name="last_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Company:</td>
<td><input type="text" name="company" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address1:</td>
<td><input type="text" name="address1" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address2:</td>
<td><input type="text" name="address2" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td><input type="text" name="city" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">State:</td>
<td><input type="text" name="state" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Zip:</td>
<td><input type="text" name="zip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Phone:</td>
<td><input type="text" name="phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cell_phone:</td>
<td><input type="text" name="cell_phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fax:</td>
<td><input type="text" name="fax" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Discipline:</td>
<td><input type="text" name="discipline" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Registration_date:</td>
<td><input type="text" name="registration_date" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Ip:</td>
<td><input type="text" name="ip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Distribution_method:</td>
<td><input type="text" name="distribution_method" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>


I also changed the SUBMITWEB_POST to get in the HTTP.Submit(). The only thing I can think of it is possibly taking the '_''s(underscore's) and '-''s(hyphen's) in the 'myvalues' table and reproducing these incorrectly when it does the submit. Is that a possiblity?

MSP
12-22-2008, 03:30 PM
Here is the correct attached picture. The other one is not right.
It is still not working properly. I did the replacement of all POST with GET and here is what I have now.
<?php require_once('Connections/connMarathon.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET["MM_insert"])) && ($_GET["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO dashboard_registration (reg_id, proj_id, first_name, last_name, company, address1, address2, city, `state`, zip, phone, cell_phone, fax, email, discipline, registration_date, ip, distribution_method) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_GET['reg_id'], "int"),
GetSQLValueString($_GET['proj_id'], "int"),
GetSQLValueString($_GET['first_name'], "text"),
GetSQLValueString($_GET['last_name'], "text"),
GetSQLValueString($_GET['company'], "text"),
GetSQLValueString($_GET['address1'], "text"),
GetSQLValueString($_GET['address2'], "text"),
GetSQLValueString($_GET['city'], "text"),
GetSQLValueString($_GET['state'], "text"),
GetSQLValueString($_GET['zip'], "int"),
GetSQLValueString($_GET['phone'], "text"),
GetSQLValueString($_GET['cell_phone'], "text"),
GetSQLValueString($_GET['fax'], "text"),
GetSQLValueString($_GET['email'], "text"),
GetSQLValueString($_GET['discipline'], "text"),
GetSQLValueString($_GET['registration_date'], "date"),
GetSQLValueString($_GET['ip'], "text"),
GetSQLValueString($_GET['distribution_method'], "text"));

mysql_select_db($database_connMarathon, $connMarathon);
$Result1 = mysql_query($insertSQL, $connMarathon) or die(mysql_error());
}
?>
<form method="GET" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Reg_id:</td>
<td><input type="text" name="reg_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Proj_id:</td>
<td><input type="text" name="proj_id" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">First_name:</td>
<td><input type="text" name="first_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Last_name:</td>
<td><input type="text" name="last_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Company:</td>
<td><input type="text" name="company" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address1:</td>
<td><input type="text" name="address1" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Address2:</td>
<td><input type="text" name="address2" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">City:</td>
<td><input type="text" name="city" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">State:</td>
<td><input type="text" name="state" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Zip:</td>
<td><input type="text" name="zip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Phone:</td>
<td><input type="text" name="phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Cell_phone:</td>
<td><input type="text" name="cell_phone" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Fax:</td>
<td><input type="text" name="fax" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email:</td>
<td><input type="text" name="email" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Discipline:</td>
<td><input type="text" name="discipline" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Registration_date:</td>
<td><input type="text" name="registration_date" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Ip:</td>
<td><input type="text" name="ip" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Distribution_method:</td>
<td><input type="text" name="distribution_method" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">&nbsp;</td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>


I also changed the SUBMITWEB_POST to get in the HTTP.Submit(). The only thing I can think of it is possibly taking the '_''s(underscore's) and '-''s(hyphen's) in the 'myvalues' table and reproducing these incorrectly when it does the submit. Is that a possiblity?