Everthing is the same as in the tut..
My code from new_conversation:
<?php # errors weergeven ini_set('display_errors',1); // 1 == aan , 0 == uit error_reporting(E_ALL | E_STRICT); if(isset($_POST['to'], $_POST['subject'], $_POST['body'])){ $error = array(); if(isset($_POST['to'])){ $errors[] = 'Je moet tenminste één naam invoeren.'; }else if(preg_match('#^[a-z, ]+$#i', $_POST['to']) == 0){ $errors[] = 'De opgegeven namen bestaan niet.' ; }else{ $user_names = explode(',', $_POST['to']); foreach($user_names as &$name){ $name = trim($name); } $user_ids = fetch_user_ids($user_names); if(count($user_ids) !== count($user_names)){ $errors[] = 'De volgende gebruikers kunnen niet gevonden worden: ' . implode(',', array_diff($user_names, array_keys($user_ids))); } } if(isset($_POST['subject'])){ $errors[] = 'Vul het onderwerp in.'; } if(isset($_POST['body'])){ $errors[] = 'Het bericht kan niet leeg zijn.'; } if ( count( $errors ) == 0 ){ create_conversation(array_unique($user_ids), $_POST['subject'], $_POST['body']); } } if(isset($errors)){ echo '<div class="msg success">Je bericht is verzonden! <a href="index.php?page=inbox">Terug naar Inbox</a></div>'; }else{ foreach ($errors as $error){ echo '<div class="msg error">'. $error . '</div>'; } } ?> <form action="" method="post"> <div> <label for="to">Ontvanger:</label> <input type="text" name="to" id="to" value="<?php if(isset($_POST['to'])) echo htmlentities($_POST['to']); ?>" /> </div> <div> <label for="subject">Onderwerp:</label> <input type="text" name="subject" id="subject" value="<?php if(isset($_POST['subject'])) echo htmlentities($_POST['subject']); ?>" /> </div> <div> <label for="message">Bericht:</label> <textarea name="body" rows="20" cols="95" id="message" ><?php if(isset($_POST['body'])) echo htmlentities($_POST['body']); ?></textarea> </div> <div> <input type="submit" value="Verstuur" /> </div> </form>And my code from private_message:
<?php // create a new conversation, making a given users a member. function create_conversation($user_ids, $subject, $body){ $subject = mysql_real_escape_string(htmlentities($subject)); $body = mysql_real_escape_string(htmlentities($body)); mysql_query("INSERT INTO conversations('converstaion_subject') VALUES('{$subject}')"); $conversation_id = mysql_insert_id(); $sql = "INSERT INTO conversations_messages(conversation_id, user_id, message_date, message_text) VALUES({$conversation_id}, {$_SESSION['user_id']}, UNIX_TIMESTAMP(), '{$body}')"; mysql_query($sql); $values = array(); $user_ids[] = $_SESSION['user_id']; foreach($user_ids as $user_id){ $user_id = (int) $user_id; $values[] = "({$conversation_id}, {$user_id}, 0, 0)"; } $sql = "INSERT INTO conversation_members(conversation_id, user_id, conversation_last_view, conversation_deleted) VALUES" . implode(", ", $values); mysql_query($sql); } ?>