<? PHP how to create local inbox between users?

  • Thread starter Thread starter Stefy
  • Start date Start date
S

Stefy

Guest
seems very simple.

you make a post form with subj and message

1.
$to = mysql_result(mysql_query('SELECT `name` FROM `users` WHERE `id`=\''.$_GET['id'].'\''),0);
of course you take all the security measures(like if id is set and if id actually exists. To check if it exists you select id from users and use mysql_num_rows. If the result of mysql_num_rows is bigger than >0, it means there is actually a person with that id).
$from = $_SESSION['name'];
$subj = mysql_real_escape_string($_POST['subject']) (check if post is is not empty)
$msg = same as above $_POST['message']

than all you need is an insert
mysql_query("INSERT INTO `inbox` (`username`,`to`,`subject`,`message`) VALUES (\'".$from."\',\'".$to."\',\'".$subject."\',\'".$message."\'");

what's so tough about it?
 
hi,
I have table is called users (username,password...etc.) and another table is called inbox (username,to,subj,msg)

table username
smith
john
sara
mary
....


when user logging successfully his session_name will appear and save(smith) ..

suppose this logged username(smith) looking to usernames profiles
(sara)
then he opened on profile ==>profile.php?id=24 in address bar

and want to send message to this profile ,, I have created htm box with subj and msg only with post submit ,how can I let php send this sub and msg using session_name (the person who is logging in) be as from: and the profile Id=24 be as to: ,,,, and insert into table inbox
so result will be

username -to-subj-msg
smith - sara - hi - how are you .

how we can do that ,,, i tried but i didnt see my insert into inbox table.
 
Back
Top