Advertisement
Guest User

Untitled

a guest
Jul 5th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 6.50 KB | None | 0 0
  1. <form class="cd-form floating-labels" action="" method="post" enctype="multipart/form-data"> <!-- Added Action and Methos to the form. -->
  2.         <fieldset>
  3.             <legend>معلومات للإتصال</legend>
  4.             <?php
  5.                 if(Input::exists()) { //Checking if there are inputs
  6.                     $validate = new Validate(); //calling Validation class
  7.                     $validation = $validate->check($_POST, array(
  8.                         'Name'  => array( //using name in the input section you can validate your inputs here
  9.                             'required'  => true, //something has to be added into the name section
  10.                             'min'       => 2, //nothing less then 2
  11.                             'max'       => 255 //nothing over 255
  12.                         ),
  13.                         'Email' => array(
  14.                             'required'  => true
  15.                         ),
  16.                         'Phone' => array(
  17.                             'required'  => false,
  18.                             'min'       => 2,
  19.                             'max'       => 255
  20.                         ),
  21.                         'City' => array(
  22.                             'required'  => true
  23.                        ),
  24.                         'uploaded_file' => array(
  25.                             'required'  => true
  26.                        )
  27.                     ));
  28.  
  29.                     if($validation->passed()) { //if validation has passed
  30.                         $user = new User(); //calling class file within the validation if statment
  31.  
  32.  
  33.                         $UploadDirectory    = 'uploads/';
  34.  
  35.                         if ($_FILES["uploaded_file"]["size"] > 5242880) {
  36.                             die("File size is too big!");
  37.                         }
  38.  
  39.                         //allowed file type Server side check
  40.                         switch(strtolower($_FILES['uploaded_file']['type']))
  41.                             {
  42.                                 //allowed file types
  43.  
  44.                                 case 'video/mpg':
  45.                                 case 'video/mpeg':
  46.                                 case 'video/mov':
  47.                                 case 'video/avi':
  48.                                 case 'video/wmv':
  49.                                 case 'video/mp4':
  50.                                     break;
  51.                                 default:
  52.                                     die('Unsupported File!'); //output error
  53.                         }
  54.  
  55.                         $File_Name          = strtolower($_FILES['uploaded_file']['name']);
  56.                         $File_Ext           = substr($File_Name, strrpos($File_Name, '.')); //get file extention
  57.                         $Random_Number      = Input::get('Email'); //Random number to be added to name.
  58.                         $NewFileName        = $Random_Number.$File_Ext; //new file name
  59.  
  60.                         move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $UploadDirectory.$NewFileName );
  61.  
  62.                         $url = "http://aim1one.com/work/suntop/uploads/".$NewFileName;
  63.  
  64.                         try {
  65.  
  66.                             $user->create(array( //adding items to a database.
  67.                                 'Name'                  => Input::get('Name'), //getting information form the form to ass to database
  68.                                 'Email'                 => Input::get('Email'),
  69.                                 'Phone'                 => Input::get('Phone'), // Email is the database table name
  70.                                 'City'              => Input::get('City'),
  71.                                 'Video'             => $url,
  72.                                 'Sent'                  => date('Y-m-d H:i:s'),
  73.                                 'IP_Address'            => $user->_ip() //Getting users IP address for security reasons
  74.                             ));
  75.  
  76.  
  77.                             //Send email to email address
  78.                             $adminEmail = 'ashraf@aimdirectmarketing.net,smart.niazi@gmail.com'; //Your own email address
  79.                             $subject = "Email from SUNTOP Video Contest";
  80.                             // Set Message
  81.  
  82.                                 $message = "Email from: " . Input::get('Name') . "<br />";
  83.                                 $message .= "Email address: " . Input::get('Email') . "<br />";
  84.                                 $message .= "City: " . Input::get('City') . "<br />";
  85.                                 $message .= "Phone: " . Input::get('Phone') . "<br />";
  86.                                 $message .= "<br /> ----- <br /> The video URL. <br />";
  87.                                 $message .= "Video: " . $url . "<br />";
  88.                                 $message .= "<br /> ----- <br /> This email was sent from SUNTOP Video Contest. <br />";
  89.                                 $message .= "Email sent: " . date('Y-m-d H:i:s') . "<br />";
  90.                                 $message .=  Input::get('Name') . " IP Addrress: " . $user->_ip() . "<br />";
  91.                             // Set From: header
  92.                             $from =  Input::get('Name') . " <" . Input::get('Email') . ">";
  93.  
  94.                             // Email Headers
  95.                             $headers = "From: " . $from . "\r\n";
  96.                             $headers .= "Reply-To: ". Input::get('Email') . "\r\n";
  97.                             $headers .= "MIME-Version: 1.0\r\n";
  98.                             $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  99.  
  100.                             $mail = mail($adminEmail, $subject, $message, $headers);
  101.  
  102.                         } catch(Exception $e) {
  103.                             die($e->getMessage());
  104.                         }
  105.                     }else{ //If validation fails display errros to screen
  106.                         echo '<div class="error-message">';
  107.                         foreach($validation->errors() as $error) {
  108.                             echo '<p>'. str_replace('_', ' ', $error), '</p><br>'; //removes any '_' in Names
  109.                         }
  110.                         echo '</div>';
  111.                     }
  112.  
  113.                 }
  114.  
  115.  
  116.  
  117.             ?>
  118.             <div class="icon">
  119.                 <label class="cd-label" for="cd-name">الإسم</label>
  120.                 <input class="user" type="text" value="<?php echo Input::get('Name'); ?>" name="Name" id="cd-name">
  121.             </div>
  122.  
  123.             <div class="icon">
  124.                 <label class="cd-label" for="cd-email">البريد الإلكتروني</label>
  125.                 <input class="email" type="email" value="<?php echo Input::get('Email'); ?>" name="Email" id="cd-email">
  126.             </div>
  127.  
  128.             <div class="icon">
  129.                 <label class="cd-label" for="cd-phone">هاتف</label>
  130.                 <input class="user" type="text" value="<?php echo Input::get('Phone'); ?>" name="Phone" id="cd-mobile">
  131.             </div>
  132.             <div class="icon">
  133.                 <label class="cd-label" for="cd-city">مدينة</label>
  134.                 <input class="user" type="text" value="<?php echo Input::get('City'); ?>" name="City" id="cd-city">
  135.             </div>
  136.         </fieldset>
  137.  
  138.         <fieldset>
  139.             <legend>حمّل الفيديو هنا</legend>
  140.             <p>حمّل واربح جالكسي تاب وتذاكر للمدينة الترفيهية، (أخر تاريخ التسجيل 30 اغسطس ٢٠١٥)</p>
  141. <p>فيلم ( mpg | mpeg | mp4 | mov | avi | wmv ) - حد أقصى 20 MB</p>
  142.                 <div class="form-group file-area">
  143.     <input type="file" class="uploaded_file" name="uploaded_file" id="uploaded_file" value="<?php echo Input::get('uploaded_file'); ?>" required="required">
  144.     <div class="file-dummy">
  145.       <div class="success">إربح رحلة إلى جزيرة سانوسا بسيغافوره والعديد من الجوائز الرائعة الأخرى</div>
  146.       <div class="default">الرجاء تحميل الفيديو الخاص بك </div>
  147.     </div>
  148.   </div>
  149.  
  150.  
  151.  
  152.             <div>
  153.                 <input type="submit" value="سجّل">
  154.             </div>
  155.         </fieldset>
  156.     </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement