
26/01/2016, 21:38
|
| | Fecha de Ingreso: enero-2016
Mensajes: 14
Antigüedad: 9 años, 2 meses Puntos: 0 | |
Respuesta: convertir este codigo en un web services <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="successdup.php";
$loginUsername = $_POST['email'];
$LoginRS__query = sprintf("SELECT email FROM usuario WHERE email=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_catalogo, $catalogo);
$LoginRS=mysql_query($LoginRS__query, $catalogo) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found - can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar = "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar ."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
}
}
$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 usuario (Nombre, email, Activo, Contra, edad) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['Nombre'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['Activo'], "int"),
GetSQLValueString($_POST['Contra'], "text"),
GetSQLValueString($_POST['edad'], "int"));
mysql_select_db($database_catalogo, $catalogo);
$Result1 = mysql_query($insertSQL, $catalogo) or die(mysql_error());
$insertGoTo = "success.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
entonces puedo tomar solamente este codigo y agregarle el json y puede que funcionar ? |