Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/01/2016, 09:18
joasimar
 
Fecha de Ingreso: enero-2016
Mensajes: 14
Antigüedad: 8 años, 3 meses
Puntos: 0
convertir este codigo en un web services

soy nuevo en el tema de los web services y no quiero desperdiciar el codigo que actualmente tengo y quiero generar un web services con este codigo oh utilizar lo mas posible de este codigo para hacer un web services alguien me puede ayudar oh aconsejar eh leido sobre que se utiliza json pero no se donde puedo agregarlo oh si tendria que crear un codigo total mente nuevo

<?php require_once('Connections/catalogo.php'); ?>
<?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'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/Pricipal.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<link href="CSS/styles/twoColLiqLtHdr.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="container">
<div class="header"><div class="headerint"><!-- end .header --><img src="imagenes/logo.jpg" width="182" height="33" alt="logo" /></div></div>
<div class="subcontenedor">
<div class="sidebar1">

<p>
<?php include_once ('includes/catalogo.php'); ?>

<!-- end .sidebar1 --></p>

</div>

<div class="content">
<h1><!-- InstanceBeginEditable name="Titulo" -->alta usuario<!-- InstanceEndEditable --></h1>
<!-- InstanceBeginEditable name="contenido" -->
<p>registro</p>
<p>&nbsp;</p>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Nombre:</td>
<td><span id="sprytextfield1">
<input type="text" name="Nombre" value="" size="32" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Email:</td>
<td><span id="sprytextfield2">
<input type="text" name="email" value="" size="32" />
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Contraseña:</td>
<td><span id="sprytextfield3">
<input type="password" name="Contra" value="" size="32" />
<span class="textfieldRequiredMsg">A value is required.</span></span></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Edad:</td>
<td><input type="text" name="edad" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="registrar" /></td>
</tr>
</table>
<input type="hidden" name="Activo" value="1" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
</script>
<!-- InstanceEndEditable --><!-- end .content --></div>
</div>
<div class="footer">
<p>pie de pagina</p>
<!-- end .footer --></div>
<!-- end .container --></div>
</body>
<!-- InstanceEnd --></html>