Little problem with message system
Posted: Sat Sep 08, 2012 9:18 am
I'm using a little different R/L system. So I gave my self a try.
I haven't done full tut on it yet.
Ok first, before I say what's that little problem, I'll show you what are those changes.
This is a way I'm using init.php file, I haven't enter anything inside from your your init.inc.php, I only connected
and view_conversation.php" which are all placed in base directory & private_message_func.php as I said earlier, at the start of the topic.
So, now I stuck at [part 09], first problem is, each time, I open page new_conversation.php it shows me as you can see on the picture http://img11.imageshack.us/img11/5598/n ... ionphp.jpg Your message has been sent! Return to your Inbox, which I still haven't write.
Here is a script:
Best regards,
Stefan
I haven't done full tut on it yet.
Ok first, before I say what's that little problem, I'll show you what are those changes.
This is a way I'm using init.php file, I haven't enter anything inside from your your init.inc.php, I only connected
require 'functions/private_message_func.php';, so here is full script:
<?php session_start(); error_reporting(0); // require 'database/connect.php'; require 'functions/general_func.php'; require 'functions/users_func.php'; require 'functions/search_func.php'; require 'functions/blog_func.php'; require 'functions/private_message_func.php'; $current_file = explode('/', $_SERVER['SCRIPT_NAME']); $current_file = end($current_file); if (logged_in() === true) { $session_user_id = $_SESSION['user_id']; $user_data = user_data($session_user_id,'user_id', 'username', 'password' ,'first_name', 'last_name', 'gender','email', 'password_recover', 'type', 'allow_email', 'profile'); //Access to 1_login.php if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } if ($current_file !== 'changepassword.php' && $user_data['password_recover'] == 1) { header('Location: changepassword.php?force'); exit(); } } $errors = array(); ?>Reason why I went this way(method), is because I really had no idea where to put some peace of your code, from your init.inc.php. So then, I created three new files: " --messages.php(which is in your case index.php), -- new_conversation.php
and view_conversation.php" which are all placed in base directory & private_message_func.php as I said earlier, at the start of the topic.
So, now I stuck at [part 09], first problem is, each time, I open page new_conversation.php it shows me as you can see on the picture http://img11.imageshack.us/img11/5598/n ... ionphp.jpg Your message has been sent! Return to your Inbox, which I still haven't write.
Here is a script:
<?php include'core/init.php'; include 'includes/overall/header.php'; ?> <section class="section"> <div class="content_box"><h2>Messages</h2></div> <div class="inner_content"> <p class="section_subname">New conversation</p> <div id="global_data"> <?php if (isset($_POST['to'], $_POST['subject'], $_POST['body'])) { $errors = array(); if (empty($_POST['to'])) { $errors[] = 'You must enter at least one name.'; } else if (preg_match('#^[a-z, ]+$#i', $_POST['to']) === 0) { $errors = 'The list of names you gave does not look valid.'; } 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[] = 'The following users could not be found: ' . implode(', ', array_diff($user_names, array_keys($user_ids))); } } if (empty($_POST['subject'])) { $errors = 'The subject cannot be empty.'; } if (empty($_POST['body'])) { $errors[] = 'The body cannot be empty.'; } if (empty($errors)) { create_conversation(array_unique($user_ids), $_POST['subject'], $_POST['body']); } } if (empty($errors)) { if (empty($errors)) { echo '<div> Your message has been sent! <a href="messages.php">Return to your Inbox</a></div>'; } else { foreach ($errors as $error) { echo '<div>', $error, '</div>'; } } } ?> <form action="" method="post" class="contact_form"> <table> <tbody> <tr> <td><label for="to">To:</label></td> <td><input type="text" name="to" maxlength="30" value="<?php if (isset($_POST['to'])) echo htmlentities($_POST['to']); ?>"></td> </tr> <tr> <td><label for="subject">Subject:</label></td> <td><input type="text" name="subject" maxlength="30" value="<?php if (isset($_POST['subject'])) echo htmlentities($_POST['subject']); ?>"></td> </tr> <tr> <td class="body"><label for="message">Body:</label></td> <td colspan="3"><textarea name="body" id="message" cols="60" rows="10"><?php if (isset($_POST['body'])) echo htmlentities($_POST['body']); ?></textarea></td> </tr> <tr> <td></td> <td colspan="1"><input type="submit" value="Send"></td> </tr> </tbody> </table> </form> </div> </div> </section> <?php include 'includes/overall/footer.php';?>Ok so, if you think this is a bad idea I went, just tell me what changes I should make now to my init.php, what peace of code ( if i should) pick from your init.inc.php and where to place it inside main.
Best regards,
Stefan