Help Please?

Started on the old forum in June 2008 · view the original in the archive · old links redirect here

4 replies · 472 views · started 18 years ago · 1 min read

3 participants
SpiderWap Lead · 622 posts #1
<?php
include("../config.php");
include("../style.php");
$site = mysql_real_escape_string($_POST['site']);
$name = mysql_real_escape_string($_POST['name']);
$pass = mysql_real_escape_string($_POST['pass']);
$o = mysql_real_escape_string($_POST['to']);
$subject = mysql_real_escape_string($_POST['subject']);
$message = mysql_real_escape_string($_POST['message']);
$date=date("D d M y - H:i");
$site=strtolower($site);
$query = "SELECT * FROM `users` WHERE `site` = '".$site."'";
$result = mysql_query($query);
$otvet = mysql_fetch_array($result);
if($otvet['site']){
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` = '".$site."' AND `name` = '".$name."' AND `pass` LIKE '".$pass."' ";
$loginresult = mysql_query($loginquery);
$loginotvet = mysql_fetch_array($loginresult);
if($loginotvet['name']){

$to= strtolower($to);
$toquery = "SELECT * FROM `users` WHERE `site` = '".$site."' AND `name` = '".$to."'";
$toresult = mysql_query($toquery);
$tootvet = mysql_fetch_array($toresult);
if($tootvet['name']){
echo "<div align=\"center\">\n";
echo "[b]Message Sent[/b]\n";
mysql_query('INSERT INTO messages(site, name, from, subject, message, date, timestamp ) VALUES 
("'.$site.'", "'.$to.'", "'.$name.'", "'.$subject.'", "'.$message.'", "'.$date.'", CURRENT_TIMESTAMP )');
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&name=$name&pass=$pass\">Messages</a>
\n";
echo "<a href=\"enter.php?site=$site&name=$name&pass=$pass\">Home</a>\n";
echo "</div>\n";
echo "<div class=\"foot\">\n";
echo "© 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't exist.\n";
echo "<hr />\n";
echo "<a href=\"messages.php?site=$site&name=$name&pass=$pass\">Messages</a>
\n";
echo "<a href=\"enter.php?site=$site&name=$name&pass=$pass\">Home</a>\n";
echo "</div>\n";
echo "<div class=\"foot\">\n";
echo "© 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='".$site."'"));
$logolink = trim($logosql[0]);
echo "<img src=\"$logosql[0]\" alt=\"Loading...\" />
\n";
echo "Username Or Password incorrect or it doesn't exist.
\n";
echo "<a href=\"index.php?site=$site\">Home</a>\n";
echo "</div>\n";
echo "<div class=\"foot\">\n";
echo "© WapX ".date ("Y")."";
echo "</div>\n";
echo "</body>\n";
echo "</html>\n";
exit();
}
}
else
{
header("location: error/notfound.php");
exit();
}
?>

SQL

CREATE TABLE `messages` (
  `id` int(6) unsigned NOT NULL auto_increment,
  `site` varchar(15) NOT NULL default '',
  `name` varchar(15) NOT NULL default '',
  `from` varchar(15) NOT NULL default '',
  `subject` varchar(15) NOT NULL default 'No Subject',
  `message` varchar(255) NOT NULL default '',
  `date` varchar(255) NOT NULL default '',
  `timestamp` varchar(255) NOT NULL default '',
  `status` varchar(15) NOT NULL default '+',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;

Just doesn't want to insert the message into the database... This is part of a new script i'm coding from scratch,,, i used this same method in my builder script and it worked. I'm more blind than ever not to see whats wrong, stupid or tired, but someone help me please grrr

crazybrumi Super moderator Principal · 1,064 posts #2

i thing i have noiced is that you have decalared $o = mysql_real_escape_string($_POST['to']);

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['from']);

Want something coded email me at sales@webnwaphost.com for a prices.

http://flagcounter.com/more/W80q

SpiderWap Lead · 622 posts #5
mysql_query("INSERT INTO `messages` (
`id` ,
`site` ,
`name` ,
`from` ,
`subject` ,
`message` ,
`date` ,
`timestamp` ,
`status` 
)
VALUES (
'', '".$site."', '".$to."', '".$name."', '".$subject."', '".$message."', '".$date."', 'CURRENT_TIMESTAMP', '+'
);");

Fixed it myself

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close