Ver Mensaje Individual
  #5 (permalink)  
Antiguo 24/06/2015, 14:19
mait
 
Fecha de Ingreso: junio-2015
Mensajes: 4
Antigüedad: 9 años, 8 meses
Puntos: 0
Respuesta: inserciones en BD cruzadas

ahy va entonces, yo con tando codigo asi junto yame mareo je

Código HTML:
Ver original
  1. <form name='sms' method='GET' action='' onsubmit='enviosmspriva();  return false'>
  2.       <textarea name='des'  id='descrip' >Tu mensaje aqui</textarea>
  3.  
  4.       <input type='hidden' name='idremi'   value='".$_REQUEST['idremi']."' />
  5.       <input type='hidden' name='iddes'   value='".$_REQUEST['iddes']."' />
  6.            
  7.       <input type='submit' name='mand' value='Enviar mensaje' onclick='prehideSms()' />
  8.  
  9. </form>


el formulario llama mediante javascrpt a este otro

Código HTML:
Ver original
  1. function objetoAjax(){
  2.     var xmlhttp=false;
  3.     try {
  4.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  5.     } catch (e) {
  6.  
  7.     try {
  8.         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  9.     } catch (E) {
  10.         xmlhttp = false;
  11.     }
  12. }
  13.  
  14. if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  15.       xmlhttp = new XMLHttpRequest();
  16.     }
  17.     return xmlhttp;
  18. }
  19.  
  20.  
  21. function enviosmspriva(){
  22.  
  23.          
  24.           divResultado = document.getElementById('preloadSmsB');
  25.  
  26.           id1=document.smspriva.iddes.value;
  27.           id2=document.smspriva.idremi.value;
  28.  
  29.           //instanciamos el objetoAjax
  30.           ajax=objetoAjax();
  31.  
  32.        
  33.           ajax.open("POST", "ajaxsms.php",true);
  34.  
  35.           ajax.onreadystatechange=function() {
  36.                      
  37.                     if (ajax.readyState==4) {
  38.                            
  39.                             divResultado.innerHTML = ajax.responseText
  40.                            
  41.                             LimpiarCampos();
  42.                     }
  43.          }
  44.          ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); exit;
  45.          
  46.          ajax.send("iddes="+id1+"&idremi="+id2)
  47. }
  48.  
  49. //función para limpiar los campos
  50. function LimpiarCampos(){
  51.  document.smspriva.id1.value="";
  52.   document.smspriva.id2.value="";
  53.  
  54. }




y de ahy vamos ahy


Código PHP:
Ver original
  1. $idDes = $_REQUEST['id1'];    
  2.   $docum = $_REQUEST['id2'];    
  3.  
  4.  
  5.  $kten ="select $conce from privados where  idusuario='$idDes' limit 1";
  6.  conecion a bd.........
  7.  
  8.     while(list($conce) = mysql_fetch_array($resulkten)){
  9.  
  10.       //miro si biene o no vacia
  11.       $existe='0';
  12.       if (in_array($conce )) { $existe='1'; }
  13.     }
  14.  
  15. if($existe!='1'){
  16.  
  17. //si viene vacia
  18. $metosms ="insert into privado ......
  19.  
  20. }else{
  21.  
  22. //si no viene vacia
  23. $metosms ="update privado set .......
  24.  
  25. }

Última edición por Triby; 24/06/2015 a las 18:30 Razón: Códigos en highlight