Sie sind auf Seite 1von 23

-

Coding

1.Connection.php

<?php

$con=mysql_connect("localhost","root","root") or die (mysql_error());

mysql_select_db("mailserver",$con);

?>

2.Registration.php

<html>

<head>

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

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

</head>

<body>

<div id="main">

<form method="" action="">

<div class="row" style="color:blue;font-size:20px;font-style:italic;text-


align:center;height:6%;">

Registration Form

</div>

<div class="row">

<div class="col">Enter your first name</div>

<div class="col1">:</div>

<div class="col2"><input type="text" onBlur="chkBlnk('fn','error')"


onKeyPress="return chkNum(event,'error')" name="fn" id="fn" title="first name" placeholder="enter
your first name" maxlength="10" required/></div>
<div class="col3" id="error"></div>

</div>

<div class="row">

<div class="col">Enter your last name</div>

<div class="col1">:</div>

<div class="col2"><input type="text" name="ln"


onBlur="chkBlnk('ln','error1')" onKeyPress="return chkNum(event,'error1')" id="ln" placeholder="enter
your last name"title="last name" maxlength="10" required/></div>

<div class="col3" id="error1"></div>

</div>

<div class="row">

<div class="col">Enter your Password</div>

<div class="col1">:</div>

<div class="col2"><input type="password" onBlur="chkPass()"


name="pwd" id="pwd" placeholder="Your password" rquired/></div>

<div class="col3" id="error2"></div>

</div>

<div class="row">

<div class="col">Enter your Conf Pass</div>

<div class="col1">:</div>

<div class="col2"><input type="password" onBlur="chkCpass()"


name="cpwd" id="cpwd" placeholder="Your confirm password" rquired/></div>

<div class="col3" id="error3"></div>

</div>

<div class="row">

<div class="col">Enter your Mobile</div>

<div class="col1">:</div>
<div class="col2"><input type="number" pattern="[0-9]*" name="pwd"
id="pwd" placeholder="Your mobile" rquired/></div>

<div class="col3"></div>

</div>

<div class="row">

<!---- div class="col">Enter your Email</div ----!>

<div class="col1">:</div>

<!-- div class="col2"><input type="email" name="eid" id="eid"


onBlur="chkEid()" placeholder="abc@gmail.com" required/></div --!>

<div class="col3" id="error5"></div>

</div---!>

<div class="row">

<div class="col">Select Your gender</div>

<div class="col1">:</div>

<div class="col2">

Male<input type="radio" name="gen" id="eid" value="m"


checked="checked" />

Female<input type="radio" name="gen" id="eid" value="f" ></div>

<div class="col3"></div>

</div>

<div class="row">

<div class="col">Choose Your hobbies</div>

<div class="col1">:</div>

<div class="col2">

Singing<input type="checkbox" name="cheklist[]" value="Singing"


rquired/>
Reading<input type="checkbox" name="cheklist[]" value="Reading"
rquired/></div>

<div class="col3"></div>

</div>

<div class="row" style="height:11%;">

<div class="col">Enter Your address</div>

<div class="col1">:</div>

<div class="col2" style="width:38%;">

<textarea></textarea></div>

<div class="col3" style="width:25%;"></div>

</div>

<div class="row">

<div class="col">Upload Your Pics</div>

<div class="col1">:</div>

<div class="col2" style="width:45%;">

<input type="file" name="f"/></div>

<div class="col3" style="width:17%;"></div>

</div>

<div class="row">

<div class="col">Select Your Country</div>

<div class="col1">:</div>

<div class="col2">

<select onFocus="chkCity()" name="cont" id="cont">

<option value="" selected="selected"


disabled="disabled">Your country</option>

<option value="india">India</option>
<option value="pakistan">Pakistan</option>

<option value="nepal">Nepal</option>

</select>

</div>

<div class="col3" id="error10"></div>

</div>

<div class="row">

<div class="col">Select Your DOB</div>

<div class="col1">:</div>

<div class="col2" style="width:40%;">

<select name="city" id="city">

<option value="" selected="selected"


disabled="disabled">Year</option>

</select>

<select name="city" id="city">

<option value="" selected="selected"


disabled="disabled">Month</option>

</select>

<select name="city" id="city">

<option value="" selected="selected"


disabled="disabled">Date</option>

</select>

</div>

<div class="col3" style="width:23%;"></div>

</div>

<div class="row">
<input type="submit" value="Register" name="send"/>

<input type="reset" value="Reset"/>

<input type="button" value="Button" name="button"/>

</div>

</form>

</div>

</body>

</html>

3.Compose.php

<?php

session_start();

include_once('connection.php');

@$to=$_POST['to'];

@$sub=$_POST['sub'];

@$msg=md5($_POST['msg']);

@$file=$_FILES['file']['name'];

$id=@$_SESSION['sid'];

$send = true;

// MESSAGE SEND SMTP

if(@$_REQUEST['send'])

if($to=="" || $sub=="" || $msg=="")

{
$err= "fill the related data first";

else

$d=mysql_query("SELECT * FROM userinfo where user_name='$to'");

$row=mysql_num_rows($d);

if($row==1)

//mysql_query("INSERT INTO usermail values('','$to','$id','$sub','$msg','',sysdate())");

$file_name = "";

if(isset($_FILES['file'])){

$errors= array();

$file_name = $_FILES['file']['name'];

$file_size =$_FILES['file']['size'];

$file_tmp =$_FILES['file']['tmp_name'];

$file_type=$_FILES['file']['type'];

$file_ext=strtolower(end(explode('.',$_FILES['file']['name'])));

$expensions= array("jpeg","jpg","png","pdf","txt","docx");

if(in_array($file_ext,$expensions)== true){

$errors[]="extension not allowed, please choose a JPEG or PNG file.";

}
if($file_size >= 2050505){

$send = false;

$errors[]='File size must be excately 2 MB';

if(empty($errors)==true){

move_uploaded_file($file_tmp,"images/".$file_name);

echo "Success";

mysql_query("INSERT INTO usermail (rec_id,sen_id,sub,msg,attachement,recDT)


values('$to','$id','$sub','$msg','$file_name',sysdate())");

$err= "message sent...";

}else{

foreach($errors as $e){

echo $e;

else

$sub=$sub."--"."msg failed";

mysql_query("INSERT INTO usermail values('','$id','$id','$sub','$msg','',sysdate())");

$err= "message failed...";


}

if(@$_REQUEST['save'])

if($sub=="" || $msg=="")

$err= "<font color='red'>fill subject and msg first</font>";

else

$query="INSERT INTO draft (uid,sub,fil,msg,cdate) values('$id','$sub','$file','$msg',sysdate())";

mysql_query($query);

$err= "message saved...";

//echo $v;

$sql=mysql_query("SELECT * FROM draft where id='$id' ");

while($dd=mysql_fetch_array($sql))

{
$rec=$dd['uid'];

$sen=$dd['sid'];

$sub=$dd['sub'];

$msg=$dd['msg'];

$att=$dd['fill'];

//store into usermail table

mysql_query("insert into usermail (rec_id,sen_id,sub,msg,attachment,date)


values('','$sen','$sub','$msg','$att','')");

//delete form draft

mysql_query("delete from draft where id='$id' and id='$v'");

?>

<html>

<style>

input[type=text]
{

width:200px;

height:35px;

</style>

<body>

<form method="post" enctype="multipart/form-data">

<table width="506" border="0">

<?php echo @$err; ?>

<tr>

<th width="213" height="35" scope="row">To</th>

<td width="277">

<input type="text" name="to" class="form-control" /> </td>

</tr>

<tr>

<th height="36" scope="row">Cc</th>

<td><input type="text" class="form-control" name="cc"/></td>

</tr>

<tr>

<th height="36" scope="row">Subject</th>

<td><input type="text" class="form-control" name="sub" value="<?php echo $sub; ?>"/></td>

</tr>

<tr>
<th height="70" scope="row">upload your file</th>

<td><input type="file" class="form-control" name="file" id="file" value="<?php echo $att; ?>"/></td>

</tr>

<tr>

<th height="52" scope="row">Msg</th>

<td><textarea rows="8" class="form-control" cols="40" name="msg" value="<?php echo $msg


?>"></textarea></td>

</tr>

<tr>

<th height="35" colspan="2" scope="row">

<input type="submit" name="send" class="btn btn-default" value="Send"/>

<input type="submit" name="save" class="btn btn-default" value="Save"/>

<input type="reset" value="Cancel" class="btn btn-default" /> </th>

</tr>

</table>

</body>

</form>

</html>