Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="cd-form floating-labels" action="" method="post" enctype="multipart/form-data"> <!-- Added Action and Methos to the form. -->
- <fieldset>
- <legend>معلومات للإتصال</legend>
- <?php
- if(Input::exists()) { //Checking if there are inputs
- $validate = new Validate(); //calling Validation class
- $validation = $validate->check($_POST, array(
- 'Name' => array( //using name in the input section you can validate your inputs here
- 'required' => true, //something has to be added into the name section
- 'min' => 2, //nothing less then 2
- 'max' => 255 //nothing over 255
- ),
- 'Email' => array(
- 'required' => true
- ),
- 'Phone' => array(
- 'required' => false,
- 'min' => 2,
- 'max' => 255
- ),
- 'City' => array(
- 'required' => true
- ),
- 'uploaded_file' => array(
- 'required' => true
- )
- ));
- if($validation->passed()) { //if validation has passed
- $user = new User(); //calling class file within the validation if statment
- $UploadDirectory = 'uploads/';
- if ($_FILES["uploaded_file"]["size"] > 5242880) {
- die("File size is too big!");
- }
- //allowed file type Server side check
- switch(strtolower($_FILES['uploaded_file']['type']))
- {
- //allowed file types
- case 'video/mpg':
- case 'video/mpeg':
- case 'video/mov':
- case 'video/avi':
- case 'video/wmv':
- case 'video/mp4':
- break;
- default:
- die('Unsupported File!'); //output error
- }
- $File_Name = strtolower($_FILES['uploaded_file']['name']);
- $File_Ext = substr($File_Name, strrpos($File_Name, '.')); //get file extention
- $Random_Number = Input::get('Email'); //Random number to be added to name.
- $NewFileName = $Random_Number.$File_Ext; //new file name
- move_uploaded_file($_FILES['uploaded_file']['tmp_name'], $UploadDirectory.$NewFileName );
- $url = "http://aim1one.com/work/suntop/uploads/".$NewFileName;
- try {
- $user->create(array( //adding items to a database.
- 'Name' => Input::get('Name'), //getting information form the form to ass to database
- 'Email' => Input::get('Email'),
- 'Phone' => Input::get('Phone'), // Email is the database table name
- 'City' => Input::get('City'),
- 'Video' => $url,
- 'Sent' => date('Y-m-d H:i:s'),
- 'IP_Address' => $user->_ip() //Getting users IP address for security reasons
- ));
- //Send email to email address
- $adminEmail = 'ashraf@aimdirectmarketing.net,smart.niazi@gmail.com'; //Your own email address
- $subject = "Email from SUNTOP Video Contest";
- // Set Message
- $message = "Email from: " . Input::get('Name') . "<br />";
- $message .= "Email address: " . Input::get('Email') . "<br />";
- $message .= "City: " . Input::get('City') . "<br />";
- $message .= "Phone: " . Input::get('Phone') . "<br />";
- $message .= "<br /> ----- <br /> The video URL. <br />";
- $message .= "Video: " . $url . "<br />";
- $message .= "<br /> ----- <br /> This email was sent from SUNTOP Video Contest. <br />";
- $message .= "Email sent: " . date('Y-m-d H:i:s') . "<br />";
- $message .= Input::get('Name') . " IP Addrress: " . $user->_ip() . "<br />";
- // Set From: header
- $from = Input::get('Name') . " <" . Input::get('Email') . ">";
- // Email Headers
- $headers = "From: " . $from . "\r\n";
- $headers .= "Reply-To: ". Input::get('Email') . "\r\n";
- $headers .= "MIME-Version: 1.0\r\n";
- $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
- $mail = mail($adminEmail, $subject, $message, $headers);
- } catch(Exception $e) {
- die($e->getMessage());
- }
- }else{ //If validation fails display errros to screen
- echo '<div class="error-message">';
- foreach($validation->errors() as $error) {
- echo '<p>'. str_replace('_', ' ', $error), '</p><br>'; //removes any '_' in Names
- }
- echo '</div>';
- }
- }
- ?>
- <div class="icon">
- <label class="cd-label" for="cd-name">الإسم</label>
- <input class="user" type="text" value="<?php echo Input::get('Name'); ?>" name="Name" id="cd-name">
- </div>
- <div class="icon">
- <label class="cd-label" for="cd-email">البريد الإلكتروني</label>
- <input class="email" type="email" value="<?php echo Input::get('Email'); ?>" name="Email" id="cd-email">
- </div>
- <div class="icon">
- <label class="cd-label" for="cd-phone">هاتف</label>
- <input class="user" type="text" value="<?php echo Input::get('Phone'); ?>" name="Phone" id="cd-mobile">
- </div>
- <div class="icon">
- <label class="cd-label" for="cd-city">مدينة</label>
- <input class="user" type="text" value="<?php echo Input::get('City'); ?>" name="City" id="cd-city">
- </div>
- </fieldset>
- <fieldset>
- <legend>حمّل الفيديو هنا</legend>
- <p>حمّل واربح جالكسي تاب وتذاكر للمدينة الترفيهية، (أخر تاريخ التسجيل 30 اغسطس ٢٠١٥)</p>
- <p>فيلم ( mpg | mpeg | mp4 | mov | avi | wmv ) - حد أقصى 20 MB</p>
- <div class="form-group file-area">
- <input type="file" class="uploaded_file" name="uploaded_file" id="uploaded_file" value="<?php echo Input::get('uploaded_file'); ?>" required="required">
- <div class="file-dummy">
- <div class="success">إربح رحلة إلى جزيرة سانوسا بسيغافوره والعديد من الجوائز الرائعة الأخرى</div>
- <div class="default">الرجاء تحميل الفيديو الخاص بك </div>
- </div>
- </div>
- <div>
- <input type="submit" value="سجّل">
- </div>
- </fieldset>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement