23/05/2017, 15:31
|
| | Fecha de Ingreso: septiembre-2013
Mensajes: 10
Antigüedad: 11 años, 4 meses Puntos: 0 | |
Respuesta: Como restar valores de un formulario con php y mysql? Formulario.php
Código:
<?php require_once('Connections/conex.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "Nivel 1,Nivel 2";
$MM_donotCheckaccess = "false";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && false) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "acceso.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?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;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form")) {
$insertSQL = sprintf("INSERT INTO autogestion (usuario, operacion, precio, name, cedula, fn, serial, plan) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['usuario'], "text"),
GetSQLValueString($_POST['operacion'], "text"),
GetSQLValueString($_POST['precio'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['cedula'], "text"),
GetSQLValueString($_POST['fn'], "text"),
GetSQLValueString($_POST['serial'], "text"),
GetSQLValueString($_POST['plan'], "text"));
mysql_select_db($database_conex, $conex);
$Result1 = mysql_query($insertSQL, $conex) or die(mysql_error());
$insertGoTo = "listar.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_conex, $conex);
$query_sagv = "SELECT * FROM autogestion";
$sagv = mysql_query($query_sagv, $conex) or die(mysql_error());
$row_sagv = mysql_fetch_assoc($sagv);
$totalRows_sagv = mysql_num_rows($sagv);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Documento sin título</title>
<link href="css/estilos.css" rel="stylesheet" type="text/css">
</head>
<body oncontextmenu="return false">
<div id="formulario">
<div id="encabezado">Activacion de Lineas CDMA y GSM</div>
<form action="<?php echo $editFormAction; ?>" method="POST" name="form" target="link">
<input type="hidden" name="usuario" value="<?php echo $_SESSION['MM_Username']; ?>">
<input type="hidden" name="operacion" value="Activacion de Linea">
<input type="hidden" name="precio" value="4000">
<label id="label_name">Nombre y Apellido:</label>
<input type="text" name="name" placeholder="Nombre y Apellido">
<label id="label_cedula">Cedula de Identidad:</label>
<input type="text" name="cedula" placeholder="Cedula de Identidad">
<label id="label_fn">Fecha de Nacimiento:</label>
<input type="text" name="fn" placeholder="Fecha de Nacimiento">
<label id="label_serial">Serial o Sim Card a Conectar:</label>
<input type="text" name="serial" placeholder="Serial o Sim Card a Conectar">
<label id="label_plan">Seleccione Plan a Activar:</label>
<select name="plan">
<option value="">Seleccione</option>
<option value="PLAN CONECTADOS">PLAN CONECTADOS</option>
<option value="INTELIPLAN 100">INTELIPLAN 100</option>
<option value="INTELIPLAN 400">INTELIPLAN 400</option>
<option value="INTELIPLAN 1.2">INTELIPLAN 1.2</option>
<option value="INTELIPLAN 3.2">INTELIPLAN 3.2</option>
<option value="BB ULTRA">BB ULTRA</option>
</select>
<input name="procesar" type="submit" id="procesar" value="Procesar">
<input id="cancelar" type="button" value="Cancelar" onclick="location.href = 'listar.php'">
<div id="linea">
<br><font color="red">CONDICIONES:</font><br>
Costo del requerimiento 4000 Bs.<br>
Una vez Procesado el requerimiento<br>
Tiene un Lapso de 24 Horas Para Cancelarlo.<br>
</div>
<input type="hidden" name="MM_insert" value="form">
</form>
</div>
</body>
</html>
<?php
mysql_free_result($sagv);
?>
Espero Pueda Ayudarme.
Saludos |