77
Email tutorial Follow more tutorials at www.23tutorials.com Page 1

Gmail tutorials

Embed Size (px)

Citation preview

Page 1: Gmail tutorials

Email tutorial

Follow more tutorials at www.23tutorials.comPage 1

Page 2: Gmail tutorials

Thanks for downloading this video sharing tutorial eBook.

You are free to distribute this eBook with your friends and colleagues. We have many tutorials like; how to create a social network tutorial like Facebook in php and JavaScript,

Ho to create twitter tutorial in php and JavaScript,

Ho to create Gmail tutorial in php and JavaScript,

Ho to create twitter web plug-in like who is online.

Visit our website to follow and download all this tutorials for free at www.23tutorials.com

Follow more tutorials at www.23tutorials.comPage 2

Page 3: Gmail tutorials

Gmail tutorialIndex.css………………………………………………………..4

Home.css......................................................................................8

Connection.php………………………………………………...25

Function.php……………………………………………………26

Registration script………………………………………………27

Login script……………………………………………...36

Show user profile name / photo script…………………41

How to search emails script…………………………….44

How to compose email script……………………………48

How to view inbox email script…………………………53

How to view full email script…………………………….57

How to reply email script………………………………..67

How to download email file script……………………….70

How to delete email script ………………………………77

How to draft email script………………………………...82

How to view draft email script…………………………..87

How to view outbox email script…………………………91

Follow more tutorials at www.23tutorials.comPage 3

Page 4: Gmail tutorials

How edit account script…………………………………..95

Index.cssThis css is for styling the index.php page.

body{

margin-left:-0%;

margin-top:0%;

margin-right:-0%;

background-color:#dddddd;

}

#index_page_header{

position:fixed;

background-color:blue;

width:1280px;

height:80px;

top:-21px;

left:0px;

z-index: 2;

}

#registration_div{

background-color:;

width:304px;

height:420px;

position:absolute;

Follow more tutorials at www.23tutorials.comPage 4

Page 5: Gmail tutorials

top:95px;

font-weight:bold;

left:7px;

border:1px solid white;

border-radius:5px;

}

h1{

color:white;

}

h2{

position:absolute;

color:green;

font-size:17px;

left:40px;

top:-12px;

}

.reg{

position:relative;

left:3px;

border-radius:4px;

border:0px;

height:30px;

width:295px;

}

#submit_bitton{

position:relative;

Follow more tutorials at www.23tutorials.comPage 5

Page 6: Gmail tutorials

background-color:blue;

left:80px;

top:-35px;

border-radius:4px;

border:0px;

height:30px;

width:125px;

color:white;

}

#login_div{

background-color:;

position:absolute;

top:0px;

margin-left:327px;

width:200px;

border:0px solid white;

}

#login_email{

position:relative;

left:3px;

border-radius:0px;

border:0px;

height:25px;

width:298px;

}

#login_password{

Follow more tutorials at www.23tutorials.comPage 6

Page 7: Gmail tutorials

position:relative;

top:2px;

left:3px;

border-radius:0px;

border:0px;

height:25px;

width:298px;

}

#login_button{

position:absolute;

background-color:blue;

left:0px;

top:60px;

border-radius:0px;

border:1px solid grey;

height:23px;

width:55px;

color:white;

}

Follow more tutorials at www.23tutorials.comPage 7

Page 8: Gmail tutorials

Home.cssThis home.css page is used to style the home.php page./* div containing profile picture */

.profile-photo{

position:absolute;

top:84px;

left:10px;

width:150px;

height:140px;

background-color:white;

border:1px solid #cce;

border-radius:6px;

}

/* profile name */

#profile_name{

position:relative;

top:-27px;

left:2px;

font-size:17px;

}

/* profile picture */

.profile_pic{

Follow more tutorials at www.23tutorials.comPage 8

Page 9: Gmail tutorials

position:absolute;

top:4px;

left:4px;

width:142px;

height:132px;

border-radius:6px;

}

/* div for uploading videos */

.upload-video-div{

position:absolute;

top:84px;

left:210px;

width:440px;

height:140px;

background-color:white;

border:1px solid #ccc;

border-radius:6px;

}

/* div for syling uploading forms like youtube */

.fileUpload {

position: relative;

overflow: hidden;

margin: 10px;

background-color:white;

height: 123px;

Follow more tutorials at www.23tutorials.comPage 9

Page 10: Gmail tutorials

width: 180px;

text-align: center;

top:-2px;

border:1px solid black;

}

.fileUpload input.upload {

position: absolute;

top: 0;

right: 0;

margin: 0;

padding: 0;

font-size: 20px;

cursor: pointer;

opacity: 0;

filter: alpha(opacity=0);

height: 100%;

text-align: center;

}

.custom-span{ font-family: Arial; font-weight: bold;font-size: 100px; color: #FE57A1}

#uploadFile{border: none;margin-left: 10px; width: 200px;}

.custom-para{font-family: arial;font-weight: bold;font-size: 24px; color:#585858;}

#photo_text{

position:absolute;

width:350px;

height:36px;

left:147px;

Follow more tutorials at www.23tutorials.comPage 10

Page 11: Gmail tutorials

top:75px;

font-size:16px;

}

#photo_comment{

position:absolute;

left:150px;

top:30px;

font-size:20px;

}

#submit_photo{

position:absolute;

width:340px;

height:50px;

left:155px;

top:120px;

font-size:24px;

background-color:white;

border:0px solid black;

color:white;

}

.preview

{

position:absolute;

left:185px;

top:-52px;

border:0px solid black;

Follow more tutorials at www.23tutorials.comPage 11

Page 12: Gmail tutorials

}

#preview

{

position:absolute;

top:60px;

color:#cc0000;

font-size:12px

}

/* end of div for syling uploading forms like youtube */

.left-bar-links{

position:absolute;

width:160px;

height:120px;

left:10px;

top:240px;

font-size:17px;

background-color:#dddddd;

border:0px solid #ccc;

color:black;

}

.left-bar-links a {

text-decoration:none;

color:black;

}

Follow more tutorials at www.23tutorials.comPage 12

Page 13: Gmail tutorials

#noticeboard{

width:780px;

height:35px;

border:0px solid #cce;

background-color:;

position:absolute;

left:20px;

top:0px;

}

.content{

width:380px;

margin:0 auto;

position:absolute;

top:37px;

left:190px;

}

#searchid

{

position:absolute;

width:480px;

border:1px solid #cce;

padding:10px;

font-size:14px;

Follow more tutorials at www.23tutorials.comPage 13

Page 14: Gmail tutorials

border-radius:5px;

}

#result

{

position:absolute;

width:480px;

padding:10px;

display:none;

top:37px;

border-top:1px;

overflow:hidden;

border:1px #CCC solid;

background-color:#cce;

}

.compose-message-header{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:84px;

margin-left:210px;

width:500px;

border-radius:3px;

border:;

padding:1px;

height:30px;

Follow more tutorials at www.23tutorials.comPage 14

Page 15: Gmail tutorials

}

.compose-message-header-text{

position:relative;

left:10px;

top:-21px;

font-size:15px;

}

.receiver_email_form{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:126px;

margin-left:210px;

width:500px;

border-radius:3px;

border:1px solid #cce;

padding:1px;

height:33px;

line-height: 1.42857143;

-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

}

Follow more tutorials at www.23tutorials.comPage 15

Page 16: Gmail tutorials

.message_subject{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:172px;

margin-left:210px;

width:500px;

border-radius:3px;

border:1px solid #cce;

padding:1px;

height:33px;

line-height: 1.42857143;

-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

}

.message-div{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:219px;

margin-left:210px;

width:500px;

border-radius:3px;

Follow more tutorials at www.23tutorials.comPage 16

Page 17: Gmail tutorials

border:1px solid #cce;

padding:1px;

height:233px;

line-height: 1.42857143;

-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

}

.message-body-container{

position:relative;

background-color:white;

color:black;

overflow: visible;

width:500px;

border-radius:1px;

border:0px solid #cce;

padding:1px;

height:233px;

}

.upload_file{

position:absolute;

top:459px;

margin-left:210px;

background-color:white;

}

Follow more tutorials at www.23tutorials.comPage 17

Page 18: Gmail tutorials

.submit-button{

background-color:blue;

position:absolute;

top:490px;

margin-left:210px;

width:90px;

height:40px;

border:1px solid #ccc;

border-radius:5px;

color:white;

}

.inbox-message-div{

background-color:white;

border: 2px solid #ccc;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

position: relative;

top:123px;

margin-left:210px;

width:500px;

border-radius:3px;

font-size:13px;

-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

}

Follow more tutorials at www.23tutorials.comPage 18

Page 19: Gmail tutorials

.sender-email{

position:absolute;

top:-13px;

margin-left:10px;

font-size:14px;

text-decoration:underline;

}

.draft_email{

position:absolute;

top:3px;

margin-left:423px;

font-size:13px;

text-decoration:none;

}

.delete_email{

position:absolute;

top:42px;

margin-left:423px;

font-size:13px;

text-decoration:none;

}

.email-subject{

position:absolute;

top:9px;

margin-left:20px;

Follow more tutorials at www.23tutorials.comPage 19

Page 20: Gmail tutorials

font-size:14px;

text-decoration:none;

}

.email-file{

position:absolute;

top:21px;

margin-left:423px;

font-size:14px;

text-decoration:none;

}

.download-file{

position:absolute;

top:11px;

margin-left:385px;

font-size:12px;

text-decoration:none;

}

.email_date{

position:absolute;

top:-10px;

margin-left:425px;

font-size:11px;

text-decoration:underline;

}

.email_text{

border:0px solid #ccc;

Follow more tutorials at www.23tutorials.comPage 20

Page 21: Gmail tutorials

position:relative;

top:30px;

margin-left:29px;

color:grey;

border-radius:0px;

font-size:16px;

padding-bottom:23px;

}

.inbox-message-div a{

text-decoration:none;

color:grey;

}

.reply-message-div{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:235px;

margin-left:210px;

width:500px;

border-radius:3px;

border:1px solid #cce;

padding:1px;

height:153px;

line-height: 1.42857143;

Follow more tutorials at www.23tutorials.comPage 21

Page 22: Gmail tutorials

-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgba(102, 175, 233, .6);

}

.reply-message-body-container{

position:absolute;

background-color:white;

color:black;

width:498px;

border-radius:0px;

border:0px solid #cce;

padding:0px;

height:151px;

top:2px;

left:2px;

padding:1px;

font-family: "lucida grande",tahoma,verdana,arial,sans-serif;

}

.reply-submit-button{

background-color:blue;

position:absolute;

top:400px;

margin-left:210px;

width:90px;

height:40px;

border:1px solid #ccc;

border-radius:5px;

Follow more tutorials at www.23tutorials.comPage 22

Page 23: Gmail tutorials

color:white; }

.reply-email-text{

position:absolute;

top:206px;

margin-left:212px;

font-size:12px;

}

/* styling the edit info page */

.edit-info-div{

position:absolute;

background-color:white;

-webkit-box-shadow: 0 3px 8px rgba(0, 0, 0, .25);

overflow: visible;

top:124px;

margin-left:210px;

width:500px;

border-radius:3px;

border:;

padding:1px;

height:270px;

}

.edit_account_form

{

width:300px;

height:30px;

Follow more tutorials at www.23tutorials.comPage 23

Page 24: Gmail tutorials

}

#submit_button

{

position:relative;

width:120px;

height:50px;

left:104px;

top:-9px;

border-radius:5px;

border:1px solid #cce;

background-color:#f4f8fb;

color:blue;

font-size:29px;

}

#position_edit_form{

position:relative;

left:24px;

top:39px;

Follow more tutorials at www.23tutorials.comPage 24

Page 25: Gmail tutorials

connection.phpThis php file connects this tutorial to the database.

<?php$mysql_hostname= "localhost";$mysql_user = "root";$mysql_password = "";$mysql_database = "learn"; //database name, you can change to yours$prefix = "";$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");mysql_select_db($mysql_database, $bd) or die("Could not select database");?>

Follow more tutorials at www.23tutorials.comPage 25

Page 26: Gmail tutorials

function.php

This php file stores the login user session.

<?phpinclude("connection.php");if(isset($_SESSION["SESS_MEMBER_ID" ] ) ) {$result = mysql_query("SELECT member_id FROM `member` WHERE `member_id`='".$_SESSION["SESS_MEMBER_ID"]." ' LIMIT 1");if(mysql_num_rows($result)) {$row = mysql_fetch_array($result);$_SESSION["logged"] = $row["member_id"];} } ?>

Registration script

Follow more tutorials at www.23tutorials.comPage 26

Page 27: Gmail tutorials

This is the registration form where user can sign up to have an email account.

Below is the database where all the user information will be kept.

CREATE TABLE IF NOT EXISTS `member` (`member_id`int(11) NOT NULL AUTO_INCREMENT,`firstname` varchar(30) NOT NULL,`secondname` varchar(30) NOT NULL,`email` varchar(30) NOT NULL,`sex` varchar(100) NOT NULL,`password` varchar(30) NOT NULL,`profile_picture` varchar(30) NOT NULL,`day` varchar(100) NOT NULL,`month` varchar(30) NOT NULL,`year` varchar(100) NOT NULL,PRIMARY KEY (`member_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Next create a page called index.php which will contain the registration page. 

Below is the index.phpFollow more tutorials at www.23tutorials.comPage 27

Page 28: Gmail tutorials

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/index.css"/>

<!-- Below is the external jquery file. please you can use yours if you have it or you can download it from the email framework in the home page. -->

<script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>

<script type="text/javascript">

//private message search engine modal box

$(function(){

$('#input_text').keyup(function(){

var a = $('#input_text').val();

//the check.php file is below after the index.php file. $.post('check.php', {"email": a },

function(data){

$('#preview').html(data);

});

});

});

</script>

</head>

<body>

<html>

Follow more tutorials at www.23tutorials.comPage 28

Page 29: Gmail tutorials

<nav id="index_page_header">

</nav>

<div id="registration_div">

<h2>Register to upload your videos</h1> <br>

<form name="myForm" action="exec.php" onsubmit="return(validate());" method="post">

<br><input type="text" name="firstname" placeholder="FIRST NAME" class="reg"><br>

<br><input type="text" name="secondname" placeholder="SECOND NAME" class="reg"><br>

<br><input type="text" name="email" placeholder="USERNAMES" class="reg" id="input_text"><br>

<br><td><input type="password" name="password" placeholder="PASSWORD" class="reg"><br>

<br><input type="password" name="retype" placeholder="RE-TYPE PASSWOED" class="reg"><br><br>

Male<input type="radio" name="sex" value="male">

Female<input type="radio" name="sex" value="female"><br><br>

<font color="green">Born on</font><br>

Day<select name="day"><option>1</option><option>2</option><option>3</option></select>

Month<select name="month"> <option>January</option><option>February</option><option>March</option><option>April</option><option>May</option><option>June</option>

Follow more tutorials at www.23tutorials.comPage 29

Page 30: Gmail tutorials

<option>July</option><option>August</option><option>September</option><option>October</option><option>November</option<option>December</option></select>

Year<select name="year" ><option>1924</option><option>1923</option><option>1922</option></select><br/><br><br><input type="hidden" name="profile_picture" value="p.jpg">

<td><input name="submit" type="submit" value="Submit" id="submit_bitton"/></td>

</form>

</div>

<div id="preview" style="width:340px; font-size:14px; border:0px solid black; position:absolute; top:230px; left:321px;">

</div>

</body>

</html>

Next is the php file call "check.php" php file used to live search if email exists already? The Jquery script for the email live search is above is above.

<?php include('connection.php'); $var= $_POST['email'];

$email = '@gmail.com';

Follow more tutorials at www.23tutorials.comPage 30

Page 31: Gmail tutorials

$femail = "[email protected]";

$smail= "$femail";

if(strpos($var, '@'))

{ echo"<p style='color:;'> Please don't add <span style='color:green;'> @</span> in your email. It is not accepted.<br>

Input only the names which will be used for your email.</p>";

}else { echo"<p style='color:;'> Your prospect email is <span style='color:green;'>$smail</span></p>";

$query = mysql_query("SELECT * FROM member WHERE email='$femail'");

if(mysql_num_rows($query) > 0)

{ echo"<p style='color:red;'> This <span style='color:green;'>$smail</span> email already exist. </p>";

}else { echo"<p style='color:red;'> This <span style='color:green;'>$smail</span> email has not be taken.</p>";

} } ?>

Next is the php file call "exec.php" which insert the registered user information into the database.

Follow more tutorials at www.23tutorials.comPage 31

Page 32: Gmail tutorials

<?php

//below variables are being assign to names of input fields in the registration form.

session_start();

include('connection.php');

$firstname=$_POST['firstname'];

$secondname=$_POST['secondname'];

$email=$_POST['email'];

$sex=$_POST['sex'];

$password=$_POST['password'];

$photo=$_POST['profile_picture'];

$day=$_POST['day'];

$month=$_POST['month'];

$year=$_POST['year'];

$fmail = "[email protected]";

$smail= "$fmail";

if(strpos($email, '@'))

{

//if the user email contains @ it will rejects the email. The user should enter only usernames which will be converted into an email echo"<p style='color:;'> Please don't add <span style='color:green;'> @</span> in your email. It is not accepted.<br>

Input only the names which will be used for your email.</p>";

}else

{

echo"<p style='color:;'> Your prospect email is <span

Follow more tutorials at www.23tutorials.comPage 32

Page 33: Gmail tutorials

style='color:green;'>[email protected]</span></p>";

$query = mysql_query("SELECT * FROM member WHERE email='$smail'");

if(mysql_num_rows($query) > 0)

{

echo"<p style='color:red;'> This <span style='color:green;'>[email protected]</span> email already exist. </p>";

}else

{

//Below insert the registered user information into the database when it has passed the above validation.

mysql_query("INSERT INTO member(firstname, secondname, email, sex, password, profile_picture, day, month, year)

VALUES( '$firstname', '$secondname', '$smail', '$sex', '$password', '$photo', '$day', '$month', '$year')");

header("location:home.php");

mysql_close($con);

//Create query

$qry="SELECT * FROM member WHERE email='$smail' AND password='$password'";

$result=mysql_query($qry);

//Check whether the query was successful or not.

if($result)

{

if(mysql_num_rows($result) > 0)

{

//register Successful

Follow more tutorials at www.23tutorials.comPage 33

Page 34: Gmail tutorials

session_regenerate_id();

$member = mysql_fetch_assoc($result);

$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];

$_SESSION['SESS_FIRST_NAME'] = $member['email'];

$_SESSION['SESS_LAST_NAME'] = $member['password'];

session_write_close();

exit();

} } } } ?>

Next is the home.php page where when the user has sign up or login, it will take him into the home.php page where he can send and receive emails, search for emails and edit account. please take note that the home.php page will be used throughout the upcoming steps in this tutorial.

//Below is the home page that the newly register user will be taken after registration is complete. // include the below php script at the top of the <!DOCTYPE> in the home.php page

<?phpsession_start();include("connection.php"); //connect to the databaseinclude("function.php"); //This is the include file above indicated above?>

Follow more tutorials at www.23tutorials.comPage 34

Page 35: Gmail tutorials

<!DOCTYPE ><HTML >

<head >

</head >

<body >

welcome to 23tutorials.com social network learning script for newbie programmers.Hopes you enjoyed this tutorial. Follow all the above email tutorials and you will benefit and learn new trick to create your own social network. Thanks</body >

</html >

Login script

Follow more tutorials at www.23tutorials.comPage 35

Page 36: Gmail tutorials

This is the login form where user can login. Below is the database where all the user information is kept which will be used for the login process.

Below is the database for the login process.

CREATE TABLE IF NOT EXISTS `member` (`member_id`int(11) NOT NULL AUTO_INCREMENT,`firstname` varchar(30) NOT NULL,`secondname` varchar(30) NOT NULL,`email` varchar(30) NOT NULL,`sex` varchar(100) NOT NULL,`password` varchar(30) NOT NULL,`profile_picture` varchar(30) NOT NULL,`day` varchar(100) NOT NULL,`month` varchar(30) NOT NULL,`year` varchar(100) NOT NULL,PRIMARY KEY (`member_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Next create a page called index.php which will contain the login form in the page.  Below is the index.php having the login form

<?php //Start sessionsession_start(); //Unset the variables stored in sessionunset($_SESSION['SESS_MEMBER_ID']);unset($_SESSION['SESS_FIRST_NAME']);unset($_SESSION['SESS_LAST_NAME']);?>

<!DOCTYPE >

<HTML >

Follow more tutorials at www.23tutorials.comPage 36

Page 37: Gmail tutorials

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/index.css"/>

</head>

<body>

<html>

<nav id="index_page_header">

<div id="login_div">

<form name="loginform" action= "loginscript.php" method="post">

<input type="text" name= "login_email" placeholder="email" id="login_email"> <br>

<input type="text" name="login_password" placeholder="password" id="login_password">

<input type="submit" name="login_button" value="login" id="login_button">

<?php

if( isset($_SESSION['ERRMSG_ARR']) && is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {

echo'<ul class="err">';

foreach ($_SESSION['ERRMSG_ARR'] as $msg) {

echo'<li>',$msg,'</li>';

}

echo'</ul>';

unset($_SESSION['ERRMSG_ARR']);

}

?>

</form>

Follow more tutorials at www.23tutorials.comPage 37

Page 38: Gmail tutorials

</div>

</nav>

</body>

</html>

Next is the php file call "loginscript.php" which will login the registered user into the database which he will be taken to the home.php page.

<?php //Start session session_start(); //Include database connection details require_once('connection.php'); //Array to store validation errors $errmsg_arr = array(); //Validation error flag $errflag = false; //Function to sanitize values received from the form. Prevents SQL injection function clean($str) { $str = @trim($str); if (get_magic_quotes_gpc()) { $str = stripslashes($str); } return mysql_real_escape_string($str); } //Sanitize the POST values $email = clean($_POST['login_email']); $password = clean($_POST['login_password']); //Input Validations if ($email == '') { $errmsg_arr[] = 'email missing'; $errflag = true; } if ($password == '') { $errmsg_arr[]= 'Password missing'; $errflag = true; } //If there are input validations, redirect back to the login form if ($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr;

Follow more tutorials at www.23tutorials.comPage 38

Page 39: Gmail tutorials

session_write_close(); header("location: index.php"); exit(); } //Create query $qry="SELECT * FROM member WHERE email='$email' AND password='$password' ";

$result=mysql_query($qry); //Check whether the query was successful or not if ($result) { if (mysql_num_rows($result) > 0) { //Login Successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_FIRST_NAME'] = $member['email']; $_SESSION['SESS_LAST_NAME'] = $member['password']; session_write_close(); header("location: home.php"); exit(); } else { //Login failed $errmsg_arr[] = 'email and password not found'; $errflag = true; if ($errflag) { $_SESSION['ERRMSG_ARR'] = $errmsg_arr; session_write_close(); header("location: index.php"); exit(); } } } else { die("Query failed"); } ?>

Next is the home.php page where when the user has sign up or login, it will take him into the home.php page where he can send and receive emails, search for emails and edit account. plesae take note that the home.php page will be used throughout the upcoming steps in this tutorial.

Follow more tutorials at www.23tutorials.comPage 39

Page 40: Gmail tutorials

//Below is the home page that the login user will be taken after login is completed. // include the below php script at the top of the <!DOCTYPE> in the home.php page

<?phpsession_start();include("connection.php");//connect to the databaseinclude("function.php");//This is the include file above indicated above?>

<!DOCTYPE ><HTML >

<head >

</head >

<body >

welcome to 23tutorials.com social network learnig script for newbies programmers.Hopes you enjoyed this tutorial. Follow all the above video social network tutorials and you will benefit and learn new trick to create your own social network. Thanks</body >

</html >

Follow more tutorials at www.23tutorials.comPage 40

Page 41: Gmail tutorials

Show user profile name / photo script

This is the view profile names and photo script where the login user can view his profile names and photo.

Below is the database for the storing the uploaded profile names and photo.

CREATE TABLE IF NOT EXISTS `member` (`member_id`int(11) NOT NULL AUTO_INCREMENT,`firstname` varchar(30) NOT NULL,`secondname` varchar(30) NOT NULL,`email` varchar(30) NOT NULL,`sex` varchar(100) NOT NULL,`password` varchar(30) NOT NULL,`profile_picture` varchar(30) NOT NULL,`day` varchar(100) NOT NULL,`month` varchar(30) NOT NULL,`year` varchar(100) NOT NULL,PRIMARY KEY (`member_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Next create a page called home.php that shows the profile names and picture.

Follow more tutorials at www.23tutorials.comPage 41

Page 42: Gmail tutorials

<?php session_start();include ("connection.php"); // connect to the database include("function.php"); //connect the login user session?>

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link rel="stylesheet" type="text/css" href="css/index.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

<script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>

<script type="text/javascript" src="script/jquery.form.js"></script>

</head>

<body>

<html>

<nav id="index_page_header">

</nav>

<div class="profile-photo">

<?php

/* select the names of the login from the database */

$member_id = $_SESSION["logged"];

$result = mysql_query("SELECT * FROM `member` WHERE `member_id`='$member_id' LIMIT 1");

echo "<table border='0px' id='profile_name'> ";

Follow more tutorials at www.23tutorials.comPage 42

Page 43: Gmail tutorials

while($row = mysql_fetch_array($result))

{

echo "<tr>";

echo "<img src='uploads/".$row['profile_picture']."' class='profile_pic'>";

echo "<td>" . $row['firstname'] .' '. $row['secondname'] . "</td >";

echo "</tr>";

}

echo "</table>";

?>

</div>

</body>

</html>

Follow more tutorials at www.23tutorials.comPage 43

Page 44: Gmail tutorials

How to search emails scriptThis is the search emails script where the login user can search for emails he wan t to mails to.

Below is the database for the storing the uploaded profile names and photo.

CREATE TABLE IF NOT EXISTS `member` (`member_id`int(11) NOT NULL AUTO_INCREMENT,`firstname` varchar(30) NOT NULL,`secondname` varchar(30) NOT NULL,`email` varchar(30) NOT NULL,`sex` varchar(100) NOT NULL,`password` varchar(30) NOT NULL,`profile_picture` varchar(30) NOT NULL,`day` varchar(100) NOT NULL,`month` varchar(30) NOT NULL,`year` varchar(100) NOT NULL,PRIMARY KEY (`member_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

Next create a page called home.php that contains the search form that will show the result of the search emails.

Follow more tutorials at www.23tutorials.comPage 44

Page 45: Gmail tutorials

<?php session_start();include ("connection.php"); // connect to the database include("function.php"); ?>

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link rel="stylesheet" type="text/css" href="css/index.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

<!-- Below is the external jquery file. please you can use yours if you have it. --> <script type="text/javascript" src="script/jquery-1.8.0.min.js"></script>

<script type="text/javascript" src="script/jquery.form.js"></script>

<script type="text/javascript">$(function(){ $(".search").keyup(function() { var searchid = $(this).val(); var dataString = 'search='+ searchid;if(searchid!=''){ type: "POST", url:"search.php", data: dataString, cache: false, success: function(html) {$("#result").html(html).show(); } }); }return false; }); jQuery("#result").live("click",function(e){ var $clicked = $(e.target); var $name = $clicked.find('.name').html();

Follow more tutorials at www.23tutorials.comPage 45

Page 46: Gmail tutorials

var decoded = $("<div/>").html($name).text(); $('#searchid').val(decoded); }); jQuery(document).live("click", function(e){ var $clicked = $(e.target); if (! $clicked.hasClass("search")){ jQuery("#result").fadeOut(); } }); $('#searchid').click(function(){ jQuery("#result").fadeIn(); }); }); </script> </head>

<body>

<html>

<nav id="index_page_header">

<!-- Below is the search engine form. -->

<div id="noticeboard">

<div class="content">

<input type="text" class="search" id="searchid" placeholder="Search for people you may know their email." />

<div id="result">

</div>

</div>

</div>

</nav>

</body>

</html>

Follow more tutorials at www.23tutorials.comPage 46

Page 47: Gmail tutorials

Create a file called search.php which will search the emails from the database.

<?php

include('connection.php');

if($_POST)

{

$query = mysql_real_escape_string($_POST['search']);

$sql = mysql_query("SELECT * FROM `member` WHERE `email` LIKE '%$query%' LIMIT 0, 5 ") or die (mysql_error());

$num_of_row = mysql_num_rows($sql);

if ($num_of_row > 0 ) {

while($row = mysql_fetch_array($sql))

{ $id = $row['member_id'];

echo "<p style='color:blue; text-decoration:none;'> ". $row['email']."</p>";

echo "<hr width='600px' style='color:white;'>";

} } else {echo "<font color='red' size='4' >No email found!</font>";

}} ?>

Follow more tutorials at www.23tutorials.comPage 47

Page 48: Gmail tutorials

How to compose email script

This is the form for sending emails. The form can send files alongside the email.

Below is the database that stores the emails.

CREATE TABLE IF NOT EXISTS `emails` (`email_id` int(11) NOT NULL AUTO_INCREMENT,`sender_id` int(11) NOT NULL,`receiver_id` int(11) NOT NULL,`sender_email` varchar(5000) NOT NULL,`receiver_email` varchar(5000) NOT NULL,`subject` varchar(5000) NOT NULL,`file_name` varchar(5000) NOT NULL,`email_body` varchar(5000) NOT NULL,`date` date NOT NULL,PRIMARY KEY (`email_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9;

Next create a page called home.php that contains form for sending emails.

Follow more tutorials at www.23tutorials.comPage 48

Page 49: Gmail tutorials

<?php

session_start();include ("connection.php"); // connect to the database include("function.php");

?>

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

</head>

<body>

<nav id="index_page_header">

</nav>

<!-- Below is the form for sending email and attatch file. -->

<form action="send-mail.php" enctype="multipart/form-data" method="POST" name="message_form" onsubmit="return(validate());">

<input name="MAX_FILE_SIZE" type="hidden" value="1000000">

<input type="text" name="receiver_email" placeholder="Send message to" class="receiver_email_form">

<input type="text" name="topic" placeholder="Subject" class="message_subject">

<div class="message-div">

<textarea class="message-body-container" name="email_body" placeholder="Type your

Follow more tutorials at www.23tutorials.comPage 49

Page 50: Gmail tutorials

message body here" > </textarea>

</div>

<input class="upload_file" name="file" type="file" title="attatch a file to your message">

<input type="submit" name="send_message" value="Submit" class="submit-button">

</form>

</body>

</html>

Create a file called send-mail.php which will insert the email the login user sends into the database.

<?php

session_start();

include("connection.php");

include("function.php");

$mail = $_POST["email_body"]; $receiver = $_POST['receiver_email']; $subject = $_POST["topic"]; $member_id = $_SESSION["logged"]; $sender_email = $_email["logged"]; $send_file = $_FILES['file']['name']; if( $send_file == "" ) {

$query = mysql_query("INSERT INTO emails(sender_id,date,sender_email,receiver_email,subject,file_name,email_body) VALUES('$member_id',NOW(),'$sender_email','$receiver','$subject','$send_file','$mail') "); echo "<script type=\"text/javascript\"> alert(\"You sent this message\"); window.location='home.php';

Follow more tutorials at www.23tutorials.comPage 50

Page 51: Gmail tutorials

</script>";

}else{

$path = "files/"; //the files is the name of the folder to store the file attach or send to an email.$valid_formats = array("docx", "pdf", "gif", "bmp" , "JPG" , "PNG" , "GIF","jpg", "png","sql"); $send_file = $_FILES['file']['name']; list($txt, $ext) = explode(".", $send_file); if(in_array($ext,$valid_formats)) {

$tmp = $_FILES['file']['tmp_name']; if(move_uploaded_file($tmp, $path.$send_file)) {

$query=mysql_query("INSERT INTO emails(sender_id,date,sender_email,receiver_email,subject,file_name,email_body) VALUES('$member_id',NOW(),'$sender_email','$receiver','$subject','$send_file','$mail') ") or die(mysql_error()); } else

{

echo "<script type=\"text/javascript\"> alert(\"photo uploaded failed\"); window.location='home.php'; </script>";

}

{

echo "<script type=\"text/javascript\">alert(\"You sent this message\");window.location='home.php';</script>";

} } else{ echo "<script type=\"text/javascript\"> alert(\"This $send_file file is invalid\");

Follow more tutorials at www.23tutorials.comPage 51

Page 52: Gmail tutorials

window.location='home.php'; </script>"; } } ?>

How to view inbox email script

Follow more tutorials at www.23tutorials.comPage 52

Page 53: Gmail tutorials

This is the view profile names and photo script where the login user can view his profile names and photo. Below is the database for the storing the inbox emails (messages).

CREATE TABLE IF NOT EXISTS `emails` (`email_id` int(11) NOT NULL AUTO_INCREMENT,`sender_id` int(11) NOT NULL,`receiver_id` int(11) NOT NULL,`sender_email` varchar(5000) NOT NULL,`receiver_email` varchar(5000) NOT NULL,`subject` varchar(5000) NOT NULL,`file_name` varchar(5000) NOT NULL,`email_body` varchar(5000) NOT NULL,`date` date NOT NULL,PRIMARY KEY (`email_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9;

Next create a page called home.php that shows the inbox message (emails received by the login users).

<?php session_start();include ("connection.php"); // connect to the database

Follow more tutorials at www.23tutorials.comPage 53

Page 54: Gmail tutorials

include("function.php"); ?>

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

</head>

<body>

<nav id="index_page_header">

</nav>

<!-- Below is the php script which selects the login user inbox emails (The user can see all the messages it receives). These inbox emails are not completed the user has to clicked the email to view the full emails.-->

<?php

$user_email = $_email["logged"];

$email = mysql_query("SELECT * FROM `emails` WHERE `receiver_email`='$user_email' ORDER BY date DESC");

$num_rows =mysql_numrows($email);

if ($num_rows != 0 ) {

while($row = mysql_fetch_array($email))

{ $email_file = $row["file_name"];

$email_text = $row["email_body"];

$mail = substr($email_text , 0, 15);

Follow more tutorials at www.23tutorials.comPage 54

Page 55: Gmail tutorials

if($email_file)

{ echo"<div class='inbox-message-div'>";

echo'<p class="sender-email"><span style="color:red;"> From:</span> '.$row["sender_email"].'</p>';

echo'<p class="email-subject"><span style="color:green;"> Subject:</span> '.$row["subject"].'</p> ';

echo'<p class="draft_email" ><a href="insert_draft.php?email_id='.$row["email_id"].'"><i class="icon icon-save"></i> draft email</a></p>';

echo'<p class="email-file"> <span style="color:green;"><i class="icon icon-file"></i> sent a file</span> </p> ';

echo'<p class="email_date"> '.$row["date"].'</p> ';

echo"<p class='email_text'> <a href='view_email.php?email_id=".$row['email_id']."'> $mail......</p></a>";

echo"</div>";

} else

{

echo"<div class='inbox-message-div'>";

echo'<p class="sender-email"><span style="color:red;"> From:</span> '.$row["sender_email"].'</p>';

echo'<p class="draft_email" ><a href="insert_draft.php?email_id='.$row["email_id"].'"><i class="icon icon-save"></i> draft email</a></p>';

echo'<p class="email-subject"><span style="color:green;"> Subject:</span> '.$row["subject"].'</p> ';

echo'<p class="email_date"> '.$row["date"].'</p> ';

echo"<p class='email_text'> <a href='view_email.php?email_id=".$row['email_id']."'> $mail......</p></a>";

echo'<p class="delete_email" ><a href="delete-mail.php?email_id='.$row["email_id"].'"><i

Follow more tutorials at www.23tutorials.comPage 55

Page 56: Gmail tutorials

class="icon icon-remove"></i> Delete</a></p>';

echo"</div>";

}}} else { echo"<div class='inbox-message-div'>";

echo"<p class='sender-email'> No message received yet.</p>";

echo"</div>";

} ?> </body>

</html>

How to view full email script

Follow more tutorials at www.23tutorials.comPage 56

Page 57: Gmail tutorials

This is the view full email script where the login user can view the complete email content when he clicks any email on the inbox.

Below is the database for the storing the inbox emails (messages).

CREATE TABLE IF NOT EXISTS `emails` (`email_id` int(11) NOT NULL AUTO_INCREMENT,`sender_id` int(11) NOT NULL,`receiver_id` int(11) NOT NULL,`sender_email` varchar(5000) NOT NULL,`receiver_email` varchar(5000) NOT NULL,`subject` varchar(5000) NOT NULL,`file_name` varchar(5000) NOT NULL,`email_body` varchar(5000) NOT NULL,`date` date NOT NULL,PRIMARY KEY (`email_id`)) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9;

Next create a page called home.php that shows the inbox message (emails received by the login users).

Follow more tutorials at www.23tutorials.comPage 57

Page 58: Gmail tutorials

<?php session_start();include ("connection.php"); // connect to the database include("function.php"); ?>

<!DOCTYPE >

<HTML >

<head>

<!-- Below is the external css for styling the index page-->

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

</head>

<body>

<nav id="index_page_header">

</nav>

<!-- Below is the php script which selects the login user inbox emails (The user can see all the messages it receives). -->

<?php

$user_email = $_email["logged"];

$email = mysql_query("SELECT * FROM `emails` WHERE `receiver_email`='$user_email' ORDER BY date DESC");

$num_rows =mysql_numrows($email);

if ($num_rows != 0 ) {

while($row = mysql_fetch_array($email))

{ $email_file = $row["file_name"];

Follow more tutorials at www.23tutorials.comPage 58

Page 59: Gmail tutorials

$email_text = $row["email_body"];

$mail = substr($email_text , 0, 15);

if($email_file)

{ echo"<div class='inbox-message-div'>";

<!-- Below is the link that contains incomplete emails that end with … when click it will take the user to the view_email.php page where he wil see the full email.-->

echo"<p class='email_text'> <a href='view_email.php?email_id=".$row['email_id']."'> $mail......</p></a>";

echo"</div>";

} else

{

echo"<div class='inbox-message-div'>";

<!-- Below is the link that contains incomplete emails when click it will take the user to the view_email.php page where he will see the full email.-->

echo"<p class='email_text'> <a href='view_email.php?email_id=".$row['email_id']."'> $mail......</p></a>";

echo"</div>";

}}} else { echo"<div class='inbox-message-div'>";

echo"<p class='sender-email'> No message received yet.</p>";

echo"</div>";

} ?> </body></html>

Follow more tutorials at www.23tutorials.comPage 59

Page 60: Gmail tutorials

Below is the view_email.php page as indicated above which shows the complete email message that was clicked from the inbox page without having the ….. Sign at the end of the email.

<?php session_start();include ("connection.php"); // connect to the database include("function.php"); //Below is the id (number) of the email that was clicked from the inbox page.$email_id = $_GET["email_id"];

?>

<!DOCTYPE >

<HTML >

<head>

<link rel="stylesheet" type="text/css" href="css/home.css"/>

<link href="css/font-awesome.css" rel="stylesheet">

</head>

<body>

<nav id="index_page_header">

</nav>

Follow more tutorials at www.23tutorials.comPage 60

Page 61: Gmail tutorials

<!-- Below is the php script which selects the completed email messages that was clicked from the inbox.(The user can see all the messages it receives). -->

<?php

$email = mysql_query("SELECT * FROM `emails` WHERE `email_id`='$email_id' ");

while($row = mysql_fetch_array($email))

{$email_file = $row["file_name"];

if($email_file)

{ echo"<div class='inbox-message-div'>";

echo'<p class="sender-email"><span style="color:red;"> From:</span> '.$row["sender_email"].'</p>';

echo'<p class="email-subject"><span style="color:green;"> Subject:</span> '.$row["subject"].'</p> ';

echo'<p class="email_date"> '.$row["date"].'</p> ';

echo'<p class="email_text" ><a href="view_email.php?email_id='.$row["email_id"].'">

'.$row["email_body"].'

</p></a>';

echo"</div>";

} else { echo"<div class='inbox-message-div'>";

echo'<p class="sender-email"><span style="color:red;"> From:</span> '.$row["sender_email"].'</p>';

Follow more tutorials at www.23tutorials.comPage 61

Page 62: Gmail tutorials

echo'<p class="email-subject"><span style="color:green;"> Subject:</span> '.$row["subject"].'</p> ';

echo'<p class="email_date"> '.$row["date"].'</p> ';

echo'<p class="email_text" ><a href="view_email.php?email_id='.$row["email_id"].'">

'.$row["email_body"].'

</p></a>';

echo"</div>";

}} ?> </body>

</html>

Please follow the remaining chapters of this tutorial at www.23tutorials.com for free and many more tutorials like how to create YouTube, Facebook, twitter and many more.

Follow more tutorials at www.23tutorials.comPage 62

Page 63: Gmail tutorials

Thanks for following this video sharing social network tutorial ebook.

You are allowed to share this ebook with your friends or colleagues. We have many tutorials like;

How to create Facebook in php and JavaScript,

How to create twitter in php and JavaScript,

How to create Gmail in php and JavaScript

And many more free tutorials all for free.

We also have plug-in like who is online (showing online users),

Facebook search engine tutorials and many more for free.

Visit our website www.23tutorials.com and get all the tutorials that you want, you can even request a tutorial and will help you.

Follow more tutorials at www.23tutorials.comPage 63