Help Please?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help Please?

    Code:
    <?php
    include("../config.php");
    include("../style.php");
    $site = mysql_real_escape_string($_POST[&#39;site&#39;]);
    $name = mysql_real_escape_string($_POST[&#39;name&#39;]);
    $pass = mysql_real_escape_string($_POST[&#39;pass&#39;]);
    $o = mysql_real_escape_string($_POST[&#39;to&#39;]);
    $subject = mysql_real_escape_string($_POST[&#39;subject&#39;]);
    $message = mysql_real_escape_string($_POST[&#39;message&#39;]);
    $date=date("D d M y - H:i");
    $site=strtolower($site);
    $query = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39;";
    $result = mysql_query($query);
    $otvet = mysql_fetch_array($result);
    if($otvet[&#39;site&#39;]){
    echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
    ?>
    <!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" xml:lang="en" >
    
    <?
    echo "<head>\n";
    echo "<title>Message Sent@".$site."</title>\n";
    echo $style;
    echo "<meta name=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";  
    echo "<meta http-equiv=\"Cache-Control\" content=\"must-revalidate\" />\n";
    echo "<meta http-equiv=\"Cache-Control\" content=\"no-cache\" />\n";
    echo "<meta http-equiv=\"Pragma\" content=\"no-cache\" />\n";
    echo "</head>\n";
    echo "<body>\n";
    $name= strtolower($name);
    $loginquery = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39; AND `name` = &#39;".$name."&#39; AND `pass` LIKE &#39;".$pass."&#39; ";
    $loginresult = mysql_query($loginquery);
    $loginotvet = mysql_fetch_array($loginresult);
    if($loginotvet[&#39;name&#39;]){
    
    $to= strtolower($to);
    $toquery = "SELECT * FROM `users` WHERE `site` = &#39;".$site."&#39; AND `name` = &#39;".$to."&#39;";
    $toresult = mysql_query($toquery);
    $tootvet = mysql_fetch_array($toresult);
    if($tootvet[&#39;name&#39;]){
    echo "<div align=\"center\">\n";
    echo "[b]Message Sent[/b]\n";
    mysql_query(&#39;INSERT INTO messages(site, name, from, subject, message, date, timestamp ) VALUES 
    ("&#39;.$site.&#39;", "&#39;.$to.&#39;", "&#39;.$name.&#39;", "&#39;.$subject.&#39;", "&#39;.$message.&#39;", "&#39;.$date.&#39;", CURRENT_TIMESTAMP )&#39;);
    echo "<hr />\n";
    echo "</div>\n";
    echo "<div align=\"left\">\n";
    echo "<hr />\n";
    echo "[b]From:[/b] ".$name."
    \n";
    echo "[b]To:[/b] ".$to."
    \n";
    echo "[b]Subj:[/b] ".$subject."
    \n";
    echo "[b]Msg:[/b] ".$message."
    \n";
    echo "[b]".$date."[/b]\n";
    echo "<hr />\n";
    echo "</div>\n";
    echo "<div align=\"center\">\n";
    echo "<a href=\"messages.php?site=$site&amp;name=$name&amp;pass=$pass\">Messages</a>
    \n";
    echo "<a href=\"enter.php?site=$site&amp;name=$name&amp;pass=$pass\">Home</a>\n";
    echo "</div>\n";
    echo "<div class=\"foot\">\n";
    echo "&copy; WapX ".date ("Y")."";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit();
    }
    else
    {
    echo "<div align=\"center\">\n";
    echo "The user [b]".$to."[/b] that you tried sending this message to doesn&#39;t exist.\n";
    echo "<hr />\n";
    echo "<a href=\"messages.php?site=$site&amp;name=$name&amp;pass=$pass\">Messages</a>
    \n";
    echo "<a href=\"enter.php?site=$site&amp;name=$name&amp;pass=$pass\">Home</a>\n";
    echo "</div>\n";
    echo "<div class=\"foot\">\n";
    echo "&copy; WapX ".date ("Y")."";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit();
    }
    }
    else
    {
    echo "<div align=\"center\">\n";
    $logosql = mysql_fetch_array(mysql_query("SELECT logo FROM sites WHERE site=&#39;".$site."&#39;"));
    $logolink = trim($logosql[0]);
    echo "<img src=\"$logosql[0]\" alt=\"Loading...\" />
    \n";
    echo "Username Or Password incorrect or it doesn&#39;t exist.
    \n";
    echo "<a href=\"index.php?site=$site\">Home</a>\n";
    echo "</div>\n";
    echo "<div class=\"foot\">\n";
    echo "&copy; WapX ".date ("Y")."";
    echo "</div>\n";
    echo "</body>\n";
    echo "</html>\n";
    exit();
    }
    }
    else
    {
    header("location: error/notfound.php");
    exit();
    }
    ?>
    SQL
    Code:
    CREATE TABLE `messages` (
      `id` int(6) unsigned NOT NULL auto_increment,
      `site` varchar(15) NOT NULL default &#39;&#39;,
      `name` varchar(15) NOT NULL default &#39;&#39;,
      `from` varchar(15) NOT NULL default &#39;&#39;,
      `subject` varchar(15) NOT NULL default &#39;No Subject&#39;,
      `message` varchar(255) NOT NULL default &#39;&#39;,
      `date` varchar(255) NOT NULL default &#39;&#39;,
      `timestamp` varchar(255) NOT NULL default &#39;&#39;,
      `status` varchar(15) NOT NULL default &#39;+&#39;,
      PRIMARY KEY  (`id`),
      UNIQUE KEY `id` (`id`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
    Just doesn&#39;t want to insert the message into the database...
    This is part of a new script i&#39;m coding from scratch,,, i used this same method in my builder script and it worked.
    I&#39;m more blind than ever not to see whats wrong, stupid or tired, but someone help me please grrr

    Click here!!!

    #2
    i thing i have noiced is that you have decalared $o = mysql_real_escape_string($_POST[&#39;to&#39;]);

    and if my eyes dont deceve me you have no field called to in the database also you have not got global for from ie

    $frm = mysql_real_escape_string($_POST[&#39;from&#39;]);
    Want something coded email me at sales@webnwaphost.com for a prices.




    Comment


      #3
      The $name gets put into messages sql at the from part.....
      $to is the username i put in at the prev page in form section....

      I dont know whats wrong

      Click here!!!

      Comment


        #4
        use
        Code:
        $to = mysql_real_escape_string($_POST[&#39;to&#39;]);
        insted of
        Code:
        $o = mysql_real_escape_string($_POST[&#39;to&#39;]);
        or
        Code:
        $to= strtolower($o);
        instead of
        Code:
        $to= strtolower($to);

        Comment


          #5
          Code:
          mysql_query("INSERT INTO `messages` (
          `id` ,
          `site` ,
          `name` ,
          `from` ,
          `subject` ,
          `message` ,
          `date` ,
          `timestamp` ,
          `status` 
          )
          VALUES (
          &#39;&#39;, &#39;".$site."&#39;, &#39;".$to."&#39;, &#39;".$name."&#39;, &#39;".$subject."&#39;, &#39;".$message."&#39;, &#39;".$date."&#39;, &#39;CURRENT_TIMESTAMP&#39;, &#39;+&#39;
          );");
          Fixed it myself

          Click here!!!

          Comment

          Working...
          X