Foros del Web » Programando para Internet » PHP »

No logro enviar

Estas en el tema de No logro enviar en el foro de PHP en Foros del Web. Hola, He estado creando un formulario y bueno, me he quedado un poco atascado a la hora de crear el código php para el envío. ...
  #1 (permalink)  
Antiguo 11/06/2011, 21:51
 
Fecha de Ingreso: abril-2009
Mensajes: 24
Antigüedad: 15 años
Puntos: 0
No logro enviar

Hola,

He estado creando un formulario y bueno, me he quedado un poco atascado a la hora de crear el código php para el envío.

Lo he creado en base a algunos ejemplos que he visto y aparte yo le he añadido varias cosas. Ahora mismo aunque defina el archivo php en el action="envio.php" me lanza un aviso javascript diciendo "submited!"

Aquí dejo el código, a aver si me pueden dar algún consejito para ver que hago mal y poder seguir indagando para echarlo a adar.

Gracias


Código HTML:
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Alex</title>

<link rel="stylesheet" type="text/css" media="screen" href="skin_files/jquery-ui.css">
<link rel="stylesheet" type="text/css" media="screen" href="skin_files/ui.css">
<link rel="stylesheet" type="text/css" media="screen" href="skin_files/tipTip.css">

<script src="skin_files/jquery_002.js" type="text/javascript"></script>
<script src="skin_files/jquery_005.js" type="text/javascript"></script>
<script src="skin_files/jquery.tipTip.js" type="text/javascript"></script>

<script type="text/javascript">
	function Suma(isChecked, valor){
		if (isChecked) {
			siniva2 = (parseFloat(document.signupForm.totalsiniva2.value) + parseFloat(valor)).toFixed(2);
            } else {
				siniva2 = (parseFloat(document.signupForm.totalsiniva2.value) - parseFloat(valor)).toFixed(2);
            }
            document.signupForm.totalsiniva2.value = siniva2;
            document.signupForm.total2.value =  siniva2;
        }
        //almaceno el valor original en una variable para saber qué tenía antes.
        var valor_viejo = 0;
        function SumaSelect(valor){
            siniva2 = (parseFloat(document.signupForm.totalsiniva2.value) + parseFloat(valor) - valor_viejo).toFixed(2);
            document.signupForm.totalsiniva2.value = siniva2;
            document.signupForm.total2.value =  siniva2;
            valor_viejo = valor;
        }  
</script>
<script type="text/javascript">

$(function(){
$(".tip").tipTip({
	maxWidth: "auto",
	delay: 5, 
	edgeOffset: 5,
	defaultPosition: "right",
	maxWidth: "200px"
	
});
});

</script>

<script type="text/javascript">
$.validator.setDefaults({
	submitHandler: function() { alert("submitted!"); },
	highlight: function(input) {
		$(input).addClass("ui-state-highlight");
	},
	unhighlight: function(input) {
		$(input).removeClass("ui-state-highlight");
	}
});

$().ready(function() {
	$.fn.themeswitcher && $('<div/>').css({
		position: "absolute",
		right: 10,
		top: 10
	}).appendTo(document.body).themeswitcher();
	
	// validate signup form on keyup and submit
	$("#signupForm").validate({
		rules: {
			nombre: "required",
			
			apellido: "required",
	
			email: {
				required: true,
				email: true
			},
			confirm_email: {
				equalTo: "#email"
			},
			poblacion: {
				required: true,
				maxlength: 40
			},
			provincia: {
				required: true,
				maxlength: 40
			},
			cp: {
				required: true,
				maxlength: 5,
				digits: true
			},
			topic: {
				required: "#newsletter:checked",
				minlength: 2
			},
			terminos: "required"
		},
		messages: {
			nombre: "Obligatorio",
			apellido: "Obligatorio",
			email: {
				required: "Obligatorio",
				email: "Introduzca un email válido"
			},
			confirm_email: {
				equalTo: "El email no coincide"
			},
			poblacion: {
				required: "Obligatorio",
				maxlength: "Máximo 40 caracteres"
			},
			provincia: {
				required: "Obligatorio",
				maxlength: "Máximo 40 caracteres"
			},
			cp: {
				required: "Obligatorio",
				maxlength: "Máximo 5 dígitos",
				digits: "Solo se permiten números"
			},

			terminos: "<b>¡No olvides aceptar!</b>"
		}
	});
	
	// propose username by combining first- and apellido
	$("#username").focus(function() {
		var nombre = $("#nombre").val();
		var apellido = $("#apellido").val();
		if(nombre && apellido && !this.value) {
			this.value = nombre + "." + apellido;
		}
	});
	
	$("#signupForm input:not(:submit)").addClass("ui-widget-content");
	
	$(":submit").button();
});
</script>

<style type="text/css">
body { font-size: 62.5%; }
label { display: inline-block; width: 100px; }
legend { padding: 0.5em; }
fieldset fieldset label { display: block; }
#commentForm { width: 500px; }
#commentForm label { width: 250px; }
#commentForm label.error, #commentForm button.submit { margin-left: 253px; }
#signupForm { width: 670px; }
#signupForm label.error {
	margin-left: 10px;
	width: auto;
	display: inline;
}
#newsletter_topics label.error {
	display: none;
	margin-left: 103px;
}
</style>

</head>
<body>
<div style="margin-left:220px;">
<form class="cmxform" id="signupForm" name="signupForm" method="get" action="">
	<fieldset class="ui-widget ui-widget-content ui-corner-all">
		<legend class="ui-widget ui-widget-header ui-corner-all">Formulario Ejemplo</legend>
		<p>
			<label for="nombre">Nombre</label>
			<input class="ui-widget-content" id="nombre" name="nombre">
		</p>
		<p>
			<label for="apellido">Apellidos</label>
			<input class="ui-widget-content" id="apellido" name="apellido">
		</p>
		<p>
			<label for="empresa">Empresa</label>
			<input class="ui-widget-content" id="empresa" name="empresa">
		</p>
		<p>
			<label for="telefono">Telefono</label>
			<input class="ui-widget-content" id="telefono" name="telefono">
		</p>
		<p>
			<label for="email">Email</label>
			<input class="ui-widget-content" id="email" name="email">
		</p>
        <p>
			<label for="confirm_email">Confirm Email</label>
			<input class="ui-widget-content" id="confirm_email" name="confirm_email" type="email">
		</p>
        <p>
			<label for="poblacion">Poblacion</label>
			<input class="ui-widget-content" id="poblacion" name="poblacion">
		</p>
        <p>
			<label for="provincia">Provincia</label>
			<input class="ui-widget-content" id="provincia" name="provincia">
		</p>
        <p>
			<label for="cp">Codigo Postal</label>
			<input class="ui-widget-content" id="cp" name="cp">
		</p>
		<p>
			<label for="terminos">Términos</label>
			<input class="checkbox ui-widget-content" id="terminos" name="terminos" type="checkbox">
		</p>
		<fieldset id="newsletter_topics" class="ui-widget-content ui-corner-all gray">
			<legend class="ui-widget-header ui-corner-all">Otros</legend>
            
            <label for="FOR">Pack</label>
                <select class="ui-widget-content" name="NAME" id="ID" onChange="SumaSelect(this.value)">
                  <option selected="selected" value="0">
                    Selecciona
                  </option>
                  <option value="10.00">
OP1                  </option>
                  <option value="20.00">
OP2                  </option>
                  <option value="30.00">
OP3                  </option>
                  <option value="40.00">
OP4                  </option>
                  <option value="50.00">
OP5                  </option>
                </select>
                <p>
                  <a href="" class="tip" title="ESTO ES UN TOOLTIP">UNO</a> <input class="ui-widget-content" type="checkbox" value="00.50" id="Prod2" name="Prod2" onClick="Suma(this.checked,this.value)">0.50 &euro;
                </p>
                <p>
                  <a href="" class="tip" title="ESTO ES UN TOOLTIP">DOS</a> <input class="ui-widget-content" type="checkbox" value="1.00" id="Prod2" name="Prod2" onClick="Suma(this.checked,this.value)">1 &euro;
                </p>
                <p>
                  <a href="" class="tip" title="ESTO ES UN TOOLTIP">TRES</a> <input class="ui-widget-content" type="checkbox" value="5.00" id="Prod4" name="Prod4" onClick="Suma(this.checked,this.value)">5 &euro;
                </p>
                <p>
                  <a href="" class="tip" title="ESTO ES UN TOOLTIP">CUATRO</a> <input class="ui-widget-content" type="checkbox" value="10.00" id="Prod3" name="Prod3" onClick="Suma(this.checked,this.value)">10 &euro;
                </p>
                <input type="hidden" value="0.00" id="totalsiniva2" name="totalsiniva2">
                <p>
                  <b><font color="#999999">Total</font></b> <input type="text" id="total2" name="total2" value="0" disabled> &euro;
                </p>


		</fieldset>
		<p>
			<button aria-disabled="false" role="button" class="submit ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit"><span class="ui-button-text">Submit</span></button>
		</p>
	</fieldset>
</form>
</div>

</body></html> 
  #2 (permalink)  
Antiguo 28/06/2011, 03:11
Avatar de repara2  
Fecha de Ingreso: septiembre-2010
Ubicación: München
Mensajes: 2.445
Antigüedad: 13 años, 7 meses
Puntos: 331
Respuesta: No logro enviar

El valor de action (action="") está vacío, esto hace que el form se envíe a la misma página con una recarga. Debes poner algo como action="envio.php"
__________________
Fere libenter homines, id quod volunt, credunt.
  #3 (permalink)  
Antiguo 28/06/2011, 07:17
Avatar de mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años
Puntos: 101
Respuesta: No logro enviar

Creí que estabas poniendo el action mediante javascript, pero no lo veo. De cualquier manera, me parece que tu pregunta es para el foro de frameworks javascript, no? Donde hay algo de PHP en esto?

Me intriga esta expresion: $(":submit").button();

Etiquetas: formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:26.