<?php
include("session/session.php");
error_reporting(0);
include("include/database.php");
$qry1="select * from user where u_id='$a'";
$res1=mysql_query($qry1);
$row1=mysql_fetch_array($res1);
if(isset($_REQUEST['submit1']))
    {
    $t1=$_POST['name'];
        $password=substr(hash('sha512',rand()),0,6);            
        $t2=md5(trim($password));
        $t3=$_POST['type'];
        $t4=$_POST['email'];
        date_default_timezone_set('Asia/Kolkata');
        $today=date('d-m-Y');
        $is=date('h:i:s');
        
        $message = '<!DOCTYPE HTML>'.
            '<head>'.
            '<style type="text/css">
  body {
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   padding-top: 0 !important;
   padding-bottom: 0 !important;
   margin:0 !important;
   width: 100% !important;
   -webkit-text-size-adjust: 100% !important;
   -ms-text-size-adjust: 100% !important;
   -webkit-font-smoothing: antialiased !important;
 }
 .tableContent img {
   border: 0 !important;
   display: block !important;
   outline: none !important;
 }
 a{
  color:#382F2E;
}

p, h1,ul,ol,li,div{
  margin:0;
  padding:0;
}

td,table{
  vertical-align: top;
}
td.middle{
  vertical-align: middle;
}
.details{width:540px;}
.details td{ background-color:#EEE; padding:5px;}
</style>'.
            '</head>'.'<body>'.
            '<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tableContent" align="center" bgcolor="#EAEAEA" style="font-family:helvetica, sans-serif;">
    <tr><td height="20" bgcolor="#EAEAEA"></td></tr>
    <tr>

      <td align="center">

        <table width="600" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
          <tr><td height="45"></td></tr>

          <tr>
            <td>
              <table width="600" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="20"></td>
                  <td align="left">
                    <div class="contentEditableContainer contentImageEditable">
                      <div class="contentEditable" >
                      <img src="http://theofferstop.com/Emailtem/images/logo.png" />
                      </div>
                    </div>
                  </td>
                </tr>
              </table>
            </td>
          </tr>

          <tr><td height="45"></td></tr>

          <tr>
            <td bgcolor="#111">
              <table width="600" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="235">
                    <table width="235" border="0" cellspacing="0" cellpadding="0">
                      <tr><td height="30" colspan="3"></td></tr>
                      <tr>
                        <td width="30"></td>
                        <td width="175">
                          <table width="175" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                              <td>
                                <div class="contentEditableContainer contentTextEditable">
                                  <div class="contentEditable" >
                                    <p style="line-height:30px;font-size:20px;color:#ffffff;">User Registration<br />
                                      <a href="http://www.theofferstop.com" target="_tab" style="color:#4D82FF; text-decoration:none;font-size:14px">Visit our website</a></p>
                                    </div>
                                  </div>
                                </td>
                              </tr>
                              <tr><td></td></tr>
                              <tr>
                                <td>
                                </td>
                              </tr>
                            </table>
                          </td>
                          <td width="30"></td>
                        </tr>
                        <tr><td height="30" colspan="3"></td></tr>
                      </table>
                    </td>
                    <td width="365">
                      <div class="contentEditableContainer contentImageEditable">
                        <div class="contentEditable" >
                         <img src="http://theofferstop.com/Emailtem/images/bigImg.jpg" data-default="placeholder" data-max-width="365" width="365" height="185" alt="Cyber Monday Deals!">
                        </div>
                      </div>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            
            <tr>
              <td>
                <table width="600" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="movableContentContainer" align="center"> 
                      
                      <div class="movableContent">
                        <table width="540" border="0" cellspacing="0" cellpadding="0">
                          <tr><td height="38"></td></tr>
                         
                                                 
                          <tr><td height="12"></td></tr>
                          <tr>
                            <td>
                              <div class="contentEditableContainer contentTextEditable">
                                <div class="contentEditable" >
                                 <p style="color:#555555;font-size:14px;line-height:22px;">
                                 <h2>REGISTRATION DETAILS</h2>
                                 <table class="details">
                                 <tr>
                                 <td style="padding:5px;">User Name</td>'.
                                
                                 $message='<td style="padding:5px;">'.$t1.'</td>
                                
                                 </tr>
                                 <tr>
                                 <td style="padding:5px;">Password</td>'.
                                 $message='<td style="padding:5px;">'.$password.'</td>
                                 </tr>
                                 <tr>
                                 <td style="padding:5px;">User Type</td>'.
                                 $message='<td style="padding:5px;">'.$t3.'</td>
                                 </tr>
                                 <tr>
                                 <td style="padding:5px;">Email Id</td>'.
                                 $message='<td style="padding:5px;">'.$t4.'</td>
                                 </tr>
                                 <tr>
                                 <td style="padding:5px;">Date</td>'.
                                 $message='<td style="padding:5px;">'.$today.'</td>
                                 </tr>
                                 <tr>
                                 <td style="padding:5px;">Time</td>'.
                                 $message='<td style="padding:5px;">'.$is.'</td>
                                 </tr>
                                 
                                 </table>
                                  </p>
                                  <br><br>
                                 
                                  TheOfferStop.com
                                </div>
                              </div>
                            </td>
                          </tr>
                          <tr><td height="37"></td></tr>
                          <tr><td><div style="border:1px solid #EBE3E3"></div></td></tr>
                        </table>
                      </div>

                </td>
              </tr>

              <tr>
                <td align="center">
                  <table width="540" border="0" cellspacing="0" cellpadding="0">
                    <tr><td height="38"></td></tr>
                    <tr>
                      <td width="454" valign="middle" class="middle">
                        <div class="contentEditableContainer contentTextEditable">
                          <div class="contentEditable" >
                            <a href="#" style="font-size:13px;line-height:19px;color:#999999;text-decoration:none;"><em>Stay in Touch!</em></a>
                          </div>
                        </div>
                      </td>
                      <td width="39">
                        <div class="contentEditableContainer contentFacebookEditable">
                          <div class="contentEditable" >
                            <img src="http://theofferstop.com/Emailtem/images/facebook.png" data-default="placeholder" data-max-width="39" width="39" height="39" alt="facebook">
                          </div>
                        </div>
                      </td>
                      <td width="8"></td>
                      <td width="39">
                        <div class="contentEditableContainer contentTwitterEditable">
                          <div class="contentEditable" >
                            <img src="http://theofferstop.com/Emailtem/images/twitter.png" data-default="placeholder" data-max-width="39" width="39" height="39" alt="twitter">
                          </div>
                        </div>
                      </td>
                    </tr>
                    <tr><td height="26"></td></tr>
                  </table>
                </td>
              </tr>

            </table>
          </td>
        </tr>

      </table>

    </td>
    <tr >
      <td height="180" bgcolor="#EAEAEA" align="center">
        <table width="540" border="0" cellspacing="0" cellpadding="0" >
          <tr><td height="55"></td></tr>
          
          <tr>
            <td align="center" style="font-size:13px;color:#999999;">
              <div class="contentEditableContainer contentTextEditable">
                <div class="contentEditable" >
                  <p >© 2014 <a href="#">TheOfferStop.com</a> | All Rights Reserved <br />

<a href="#">Privacy Policy</a> | <a href="#">Terms and Conditions</a><br />

If you have any questions, contact us on <a href="#">support@theofferstop.com</a>
            </p>
                </div>
              </div>

            </td>
          </tr>
        </table>
      </td>
    </tr>

  </table>'.
            '</body>';            
            
            
            //  MAKE SURE THE "FROM" EMAIL ADDRESS DOESN'T HAVE ANY NASTY STUFF IN IT
            
            //$pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"; 
           // if (preg_match($pattern, trim(strip_tags($_POST['req-email'])))) { 
           //     $cleanedFrom = trim(strip_tags($_POST['req-email'])); 
            //} else { 
           //     return "The email address you entered was invalid. Please try again!"; 
           // } 
            
            
            
            
            //   CHANGE THE BELOW VARIABLES TO YOUR NEEDS
             
            $to = "$t4";
            
            $subject = 'User Registration';
            
            $headers = "From: Admin@theofferstop.com\r\n";
$headers .= "BCc: jeevan0824@gmail.com\r\n";
            $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n";
            $headers .= "MIME-Version: 1.0\r\n";
            $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

            if (mail($to, $subject, $message, $headers)) {
              echo 'Your message has been sent.';
            } else {
              echo 'There was a problem sending the email.';
            }
        
        $qry11="select * from user where `email`='$t4'";
        $ex11=mysql_query($qry11);
        $num=mysql_num_rows($ex11);
        if($num<=0)
        {
        $qry_a="INSERT INTO `user`(`u_name`, `u_password`, `type`, `email`) VALUES ('$t1','$t2','$t3','$t4')";
        $res_a=mysql_query($qry_a);
        }
        if($res_a)
    {
        header("location:user.php");
    }
}
    if(isset($_REQUEST['cancel1']))
    {
        header("location:user.php");
    }
?>
<style>
.d1{
    margin-left:90px;
}
.d2{
    width: 500px;
    height: 100px;
    margin-top: 50px;
}
.d3{
    margin-top: 20px;
    margin-left: 100px;
}
</style>
<script type="text/javascript">
function valid()
{
            if(document.getElementById("emailValid").value!="")
        {
            if(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test(document.getElementById("emailValid").value))
            {
            //    return true;
            }
            else
            {
                 var input = document.getElementById ("emailValid");
                 input.value="";
                 input.placeholder = "Not a valid entry";                
                return false;
            }
         }
        else
        {
             var input = document.getElementById ("emailValid");
                 input.placeholder = "Not a valid entry";            
                 return false;
        }
}
</script>
<form method="post" action=""  enctype="multipart/form-data">
<div class="d1">  
<table class="d2">                    
   <tr><td>Enter the user name:</td>
      <td><input type="text" name="name"></td>
  </tr>
  <tr><td>Type:</td>
      <td><select name="type">
      <option value="dataentry">User</option>
      <option value="admin">Admin</option>
      </select></td>
  </tr>
  <tr><td>Email Id:</td>
      <td><input type="text" name="email" id="emailValid"></td>
  </tr>
 
</table> 
      <div class="d3">
      <input type="submit" value="Save" class="btn" name="submit1" onclick="return valid()" />
      <input type="submit" class="btn" value="Cancel" name="cancel1" data-dismiss="modal"/>
    </div>  
    </div> 

</form>                   


