I am new to this forum and I hope that i'll finally find some answers here.
I am doing simple PM system on my website and I'm stuck on one part of the code. I am currently making "send message" part of pm system which should be simple but i can't figure out where i went wrong so here is the code to which form is submitted.
After posting form i get blank page without any error or result. I dunno what's wrong :\
Code: Select all
<?php
include 'mysql/config.php';
$subject = $_POST['subject'];
$touser = $_POST['touser'];
$body = $_POST['body'];
$fromuser = $_POST['fromuser'];
$receiver = mysql_query("SELECT username FROM userlist WHERE username = '".$touser."'") or die('Nije mogu?e prona?i ovog korisnika');
$checkrec = mysql_num_rows($receiver);
if(($checkrec) == 0) {
echo "Korisnik kojemu pokušavate poslati poruku ne postoji. <br /><br />
<form action='index.php?page=mojprofil&subpage=newmessage' method='post'>
<input type='submit' value='Pokušajte ponovno' class='submit' />
</form>";
exit;
}
elseif(strlen($body)) < 1){
echo "Nije mogu?e poslati praznu poruku. <br /><br />
<form action='index.php?page=mojprofil&subpage=newmessage' method='post'>
<input type='submit' value='Pokušajte ponovno' class='submit' />
</form>";
exit;
}
elseif(strlen($subject)) < 1){
echo "Nije mogu?e poslati poruku bez Naslova. <br /><br />
<form action='index.php?page=mojprofil&subpage=newmessage' method='post'>
<input type='submit' value='Pokušajte ponovno' class='submit' />
</form>";
exit;
}
else{
$insert = mysql_query("INSERT INTO pm_inbox SET from_user = '".$fromuser."', to_user = '".$touser."', subject = '".$subject."', body = '".$body."'") OR die("Nije mogu?e poslati poruku: <br />" .mysql_error());
if($insert){ echo 'Poruka uspješno poslana';}
if(!$insert) { echo 'Poruka nije poslana. ';}
}
?>