Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- mysql_connect('localhost', 'root', '');
- mysql_select_db('friend_system');
- ?>
- function getuser ($id, $field){
- $query = mysql_query("SELECT $field FROM users WHERE id='$id'");
- $run = mysql_fetch_array($query);
- return $run[$field];
- }
- ?>
- if(empty ($username) or empty ($password)){
- $message = "Fields Empty, Please re-check the form";
- } else {
- mysql_query("INSERT INTO users VALUES('','".$username."','".md5($password)."')");
- $message = "Registration completed! You can now log in!";
- }
- echo "<div class='box'>$message</div>";
- }
- ?>
- User Name: <br/>
- <input type='text' name='username' autocomplete='off' />
- <br/><br/>
- Password: <br/>
- <input type='password' name='password' />
- <br/><br/>
- <input type='submit' name='submit' value='Register' />
- </form>
- <?php include 'connect.php';?>
- <?php include 'functions.php' ?>
- <form method='post'>
- <?php
- if(isset($_POST['submit'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty ($username) or empty ($password)){
- $message = "Fields Empty, Please re-check the form";
- } else {
- $check_login = mysql_query("SELECT id FROM users WHERE username='$username' AND password='".md5($password)."'");
- if (mysql_num_rows ($check_login) == 1) {
- $get = mysql_fetch_array($check_login);
- $user_id = $get['id'];
- $_SESSION['user_id'] = $user_id;
- header('location: index.php');
- } else {
- $message = "User name or Password incorrect";
- }
- }
- echo "<div class='box'>$message</div>";
- }
- ?>
- User Name: <br/>
- <input type='text' name='username' autocomplete='off' />
- <br/><br/>
- Password: <br/>
- <input type='password' name='password' />
- <br/><br/>
- <input type='submit' name='submit' value='Login' />
- </form>
- <?php include 'connect.php';?>
- <?php include 'functions.php' ?>
- <?php include 'header.php' ?>
- <?php
- $my_id = $_SESSION['user_id'];
- ?>
- <div class="container">
- <h1>Inbox</h1>
- <?php
- $my_id = $_SESSION['user_id'];
- $msg_query = mysql_query("SELECT * FROM messages WHERE recepient_id='$my_id'");
- while($run_msg = mysql_fetch_array($msg_query)) {
- $sender_id = $run_msg['sender_id'];
- $subject = $run_msg['subject'];
- $content = $run_msg['content'];
- $user = $sender_id;
- $username = getuser($user, 'username'); //functions.php
- ?>
- FROM: <br/></br> </br>
- <?php
- echo "<a href='profile.php?user=$user' class='box' style='display:box'>$username</a></br> </br> ";
- echo "<p class='box' style='color:blue;'>$subject </p> " ;
- echo "<p class='box' style='color:green;'>$content</p></br> </br> ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement