What is suppose to happen here is when the data gets posted via the form its to first check for user name and password (same time grab the id) from one table. Next it checks a different table to see if a user is in that table, if so it adds 1 to a field, if not it creates a new row.
My problem is that nothing below my echo of 'connected' is running(other than the include when the page isnt posted)
im guessing its something with all my if statements but my eyes are bugging out and i cant find it
any help would be much appricated
also if this is in the wrong section (even tho it works with db), im sorry
thx
<?php
if ($_POST['action'] == "send") {
$urn = strtolower($_POST['username']);
$urn = str_replace(';', '', $urn);
$urn = stripslashes($urn);
$urn = str_replace('%', '', $urn);
$urp = strtolower($_POST['password']);
$urp = str_replace(';', '', $urp);
$urp = stripslashes($urp);
$urp = str_replace('%', '', $urp);
$whom = strtolower($_POST['whom']);
$whom = str_replace(';', '', $whom);
$whom = stripslashes($whom);
$whom = str_replace('%', '', $whom);
$server = $_POST['server'];
$server = str_replace(';', '', $server);
$server = stripslashes($server);
$server = str_replace('%', '', $server);
$why = $_POST['why'];
$why = str_replace(';', '', $why);
$why = stripslashes($why);
$why = str_replace('%', '', $why);
$datearray = getdate();
$year = $datearray["year"];
$month = $datearray["mon"];
$day = $datearray["mday"];
$hour = $datearray["hours"];
$minute = $datearray["minutes"];
$seconds = $datearray["seconds"];
$dat = "$year:$month:$day";
$tim = "$hour:$minute:$seconds";
if (!$urn && !$urp && !$whom && !$server && !$why){
print "Please complete all fields before sending your message.";
exit;
}
######connect
$dblink = mysql_pconnect('', '', '') or die('Could not connect to the database: ' .mysql_error());
mysql_select_db('') or die('Could not select database');
$datafromdb="SELECT * FROM account_data WHERE name=\"$urn\"";
$thedata=mysql_query($datafromdb);
echo ("connected <br>");
#####grab id and password of person
if (mysql_num_rows($thedata) > 0) {
$getpassword = mysql_query("SELECT * FROM account_data WHERE urn=\"$urn\"");
$list = mysql_fetch_array($getpassword);
$idnum = $list['id'];
$selpassword = $list['urp'];
#####check password
if ($selpassword == "$urn") {
$result1 = mysql_query("SELECT COUNT(*) FROM main_data WHERE whom='$whom'");
#####password good check if whom is in db
if (mysql_result($result1, 0) > 0) {
#####yes, k update their count
$result2 = mysql_query("SELECT counter FROM main_data WHERE whom='$whom'");
$result3 = $result2 + 1;
$result4 = "INSERT INTO main_data (counter) VALUES (\"$result4\")";
$sql = mysql_query($result4);
exit;
} else {
#####no match so create one
$sql2 = "INSERT INTO main_data (server, date, time, submitter, whom, why) VALUES (\"$server\", \"$dat\", \"$tim\", \"$idnum\", \"$whom\", \"$why\")";
$result = mysql_query($sql2);
}
}else{
echo "Invalid password, if you are having problems email [email]itspappy@gmail.com[/email]";
}
}
}else{
##### include form when not posting the data
include ("forma.php");
}
?>
small problems where it says name= should have been urn=
where it says if ($selpassword == "$urn") { should have been $urp
everything is good to go thx tho!