Ver Mensaje Individual
  #5 (permalink)  
Antiguo 29/04/2010, 11:24
den_22
 
Fecha de Ingreso: enero-2010
Mensajes: 198
Antigüedad: 14 años, 3 meses
Puntos: 1
Respuesta: problema id de usuario

Hola gracias por responder, ahora cambié un par de cosas; el tema es que no se insertan los mensajes en la bd.

el contactuser.php:

Código PHP:
Ver original
  1. <?php
  2. error_reporting(E_ALL ^ E_NOTICE);
  3. session_name('pLogin');
  4.  
  5.  
  6. include("connect.php");
  7.  
  8. $usuario=$_SESSION['usuario'];
  9. $id=$_SESSION['mid'];
  10. $fid=$_SESSION["id"];
  11.  
  12.  
  13. $subject="";
  14. $msg="";
  15. $label="Reply";
  16. $tid=0;
  17. if(isset($_REQUEST["tid"]))
  18. {
  19. $tid=$_REQUEST["tid"];
  20. }
  21. elseif(isset($_REQUEST["id"]))
  22. {
  23.     $label="Contact Member";
  24.     $id=$_REQUEST["id"];
  25.     $tid=$_REQUEST["id"];
  26.    
  27. }
  28.  
  29. if(isset($_REQUEST["type"])&&($_REQUEST["type"]=="contact"))
  30. {
  31. $label="Send IM";
  32. }
  33. if(isset($_REQUEST["mid"]))
  34. {
  35. $mid=$_REQUEST["mid"];
  36. $rst0=mysql_fetch_array(mysql_query("select * from messages where id='$id'"));
  37. $subject="Re:".$rst0["dm_subject"];
  38. $msg="MESSAGE:: ".$rst0["dm_message"];
  39. }
  40.  
  41.  $row=mysql_fetch_array(mysql_query("select * from members where id=$tid"));
  42.           if(!$row)
  43.           {
  44.             echo "<p>&nbsp;</p><p>&nbsp;</p><br><br><br><div align='center'><font size=2 color='#333333' face='Arial, Helvetica, sans-serif'>Recipient Not Found. Click <a href='index.php' class='insidelink'>here</a> to continue</font></div><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>";
  45.             return;
  46.           }
  47.           else
  48.           {
  49.  
  50.  
  51. ?>
  52.  
  53. <script language="javascript" >
  54.  //<!--
  55.  function Validate(form)
  56.  {
  57.  if(form.subject.value== "")
  58.  {
  59.  alert ('Ingresa el Asunto!');
  60.  form.subject.focus();
  61.  return false;
  62.  }
  63.  if(form.subject.value.match(/[&<>]+/))
  64.  {
  65.  alert("Remueve los caracteres inválidos del Asunto (e.j. &  < >)");
  66.  form.subject.focus();
  67.  return(false);
  68.  }
  69.  
  70.  if(form.message.value== "")
  71.  {
  72.  alert ('Ingresa tu Mensaje!');
  73.  form.message.focus();
  74.  return false;
  75.  }
  76.  if(form.message.value.match(/[&<>]+/))
  77.  {
  78.  alert("Remueve los caracteres inválidos del Mensaje (e.j. &  < >)");
  79.  form.message.focus();
  80.  return(false);
  81.  }
  82.  
  83.  return true;
  84.  }
  85.  //-->
  86.  </script>
  87.  
  88. <table width="100%" border="0" cellpadding="0" cellspacing="0" >
  89.   <tr>
  90.     <td  valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
  91.         <tr>
  92.           <td valign="middle" align="center"><font class="normal">
  93.  
  94.             <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0" class="onepxtable">
  95.                       <tr>
  96.                         <td height="25"  class="titlestyle">&nbsp;<?php echo $label;?></td>
  97.                       </tr>
  98.               <tr>
  99.                 <td>
  100.                     <table width="100%" border="0" align="center" cellpadding="2" cellspacing="5" ><form name="form1" method="post"  onSubmit="return Validate(this);" action="insert_message.php">
  101.                       <tr>
  102.                         <td width="40%" height="25" valign="top"  class="innertablestyle">
  103.                           <div align="right"><strong>Para</strong></div></td>
  104.                         <td width="6" height="25" valign="top">&nbsp;</td>
  105.                         <td width="60%" height="25" valign="top"><font class='normal'>
  106.                           <input type="text" name="to"  readonly="" value=" <?php
  107.       echo $row["usuario"];?>">
  108.                           </font> </td>
  109.                       </tr>
  110.                       <tr>
  111.                         <td width="40%" height="25" valign="top"  class="innertablestyle">
  112.                           <div align="right"><strong><font size="2">Asunto:</font></strong></div></td>
  113.                         <td width="6" height="25" valign="top"><font size="2"><strong><font class='normal'><font class='red'>*</font>
  114.                           </font></strong></font></td>
  115.                         <td width="60%" height="25" valign="top"><font class='normal'>
  116.                           <input name="subject" type="text" size="60" <?php
  117.         echo "value='" .$subject. "'";
  118.         ?> >
  119.                           <input name="fid" type="hidden" value="<?php echo $fid; ?>">
  120.                           <input name="id" type="hidden" value="<?php echo $tid; ?>">
  121.                           <input name="sb_type" type="hidden" id="sb_type" value="<?php
  122.                           if(isset($_REQUEST["sb_type"]))                        
  123.                           { echo $_REQUEST["sb_type"];}
  124.                           else
  125.                           {echo 0;} ?>">
  126.                           <input name="id" type="hidden" id="id" value="<?php
  127.                           if(isset($_REQUEST["id"]))                         
  128.                           { echo $_REQUEST["id"];}
  129.                           else
  130.                           {echo 0;} ?>">
  131.                           </font></td>
  132.                       </tr>
  133.                       <tr>
  134.                         <td width="40%" height="25" valign="top"  class="innertablestyle">
  135.                           <div align="right"><font size="2"><strong>Mensaje<font class='normal'></font> </strong></font></div></td>
  136.                         <td width="6" height="25" valign="top"><font size="2"><strong><font class='normal'><font class='red'>*</font>
  137.                           </font></strong></font></td>
  138.                         <td width="60%" height="25"  valign="top"> <div align="left"><font class='normal'>
  139.                             </font>
  140.                             <textarea name="message" cols="60" rows="10"><?php echo $msg;?></textarea>
  141.                           </div></td>
  142.                       </tr>
  143.                       <tr>
  144.                         <td width="40%" height="25" valign="top"  class="innertablestyle"></td>
  145.                         <td width="6" height="25" valign="top">&nbsp;</td>
  146.                         <td width="60%" height="25"  valign="top"> <input type="submit" name="Submit" value="Post Message"></td>
  147.                       </tr>
  148.                </form> </table>
  149.                   </td>
  150.               </tr>
  151.             </table>
  152.            </font></td>
  153.         </tr>
  154.       </table></td>
  155.   </tr>
  156.  
  157. </table>
  158.  
  159. <?php
  160. }
  161.  
  162.  
  163.  
  164. ?>

el insert_message.php:

Código PHP:
Ver original
  1. <?php
  2.  error_reporting(E_ALL ^ E_NOTICE);
  3. session_name('pLogin');
  4. include("connect.php");
  5.  
  6. $id=$_SESSION['id'];
  7. $usuario=$_SESSION['usuario'];
  8. $from_mem=$_SESSION['id'];
  9.  
  10.  
  11. $tid=$_REQUEST["id"];
  12. $fid=$_SESSION["id"];
  13.  
  14. $row=mysql_fetch_array(mysql_query("select * from members where id=$tid"));
  15. $from_mem=mysql_fetch_array(mysql_query("select * from members where id=$fid"));
  16.  
  17.  
  18.             if (!get_magic_quotes_gpc()) {
  19.             $message=str_replace('$', '\$',addslashes($_REQUEST["message"]));
  20.             $subject=str_replace('$', '\$',addslashes($_REQUEST["subject"]));
  21.             }
  22.             else
  23.             {
  24.             $message=str_replace('$', '\$',$_REQUEST["message"]);
  25.             $subject=str_replace('$', '\$',$_REQUEST["subject"]);
  26.             }
  27.  
  28.        
  29. mysql_query ("Insert into 'messages' ( dm_fid , dm_tid , dm_message , dm_subject , dm_msg_read,d_f_del,d_t_del,  dm_onstamp) VALUES ( '$fid','$tid','$message'," ."'$subject'" .",'No','No','No','" .date("YmdHis",time())."')");
  30.  
  31.  
  32. //Gets member info
  33.     $sql = "SELECT max(id) FROM messages" ;
  34.     $rs_query=mysql_query($sql);
  35.     $rs=mysql_fetch_array($rs_query);
  36.     $id=$rs[0];
  37.    
  38.     $rs_query=mysql_query($sql);
  39.    
  40.     if ( $rs=mysql_fetch_array($rs_query)  )
  41.       {
  42.          if($rs["sb_status"]=="yes")   
  43.           {
  44.                      $from =$rs["dm_fid"];
  45.                      $to = $rs1["email"];
  46.                      $subject =$row["dm_subject"];
  47.            
  48.              $body=str_replace("%email%", $sb_null_char,str_replace("%pass%",$sb_null_char,str_replace("%lastname%", $rs1["lastname"],str_replace("%firstname%", $rs1["firstname"],str_replace("%usuario%",$rs1["usuario"], $row["email"]) ))));
  49.                
  50.             $body=str_replace("%signup_url%",$sb_null_char,str_replace("%login_url%",$login_url,$body));
  51.  
  52.          $body=str_replace("%message_text%",$rs0["dm_message"],str_replace("%message_title%",$rs0["dm_subject"],str_replace("%sender_username%",$rs2["usuario"],str_replace("%message_date%",$ondate,$body))));
  53.              
  54.               $header="From:" . $from . "\r\n" ."Reply-To:". $from  ;
  55.              if(isset($rs["sb_html_format"])&&($rs["sb_html_format"]=="yes"))
  56.             {
  57.             $header .= "\r\nMIME-Version: 1.0";
  58.             $header .= "\r\nContent-type: text/html; charset=iso-8859-1\r\n";
  59.         //  $body=str_replace("\n","<br>",$body);
  60.             }
  61.  
  62. //  echo "--from:-$from----to:-$to---sub:-$subject----head:-$header----";
  63.     //echo "<pre>$body</pre>";
  64.     //die();
  65.                 if( $rs["sb_status"]=='yes')
  66.                      mail($to,$subject,$body,$header);
  67.  
  68.           }// end if status is on
  69.  
  70.          
  71.       }
  72.     $errmsg="Tu mensaje ha sido enviado a  ".$row["usuario"];
  73.  
  74.  
  75. header("Location:"."msg_confirm_mem.php?tid=$tid&id=".$fid."&sb_type=".$_REQUEST["sb_type"]."&errmsg=".urlencode($errmsg));
  76. die();
  77. ?>

entonces ahora si muestra en la url
$tid --- esta es la id a la que va dirigido el mensaje
$fid---esta es la id del usuario que lo envia

Pero al ir a la base de datos no se insertan los mensajes.

Debe haber algun error en el insert_message