Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" </script>
- <script type="text/javascript">
- $(document).ready(function() {
- $("#submit_custom").click(function() {
- var proceed = true;
- $("#upload_form input[required=true]").each(function(){
- $(this).css('border-color','');
- if(!$.trim($(this).val())){ //if this field is empty
- $(this).css('border-color','red'); //change border color to red
- proceed = false; //set do not proceed flag
- }
- if(proceed)
- post_data = {
- 'file': $('input[name=file]').val(),
- 'trxid': $('input[name=trxid]').val(),
- 'orderid': $('input[name=orderid]').val(),
- 'custid': $('input[name=custid]').val()
- };
- $.post('upload.php', post_data, function(response){
- if(response.type == 'error'){ //load json data from server and output message
- output = '<div class="error">'+response.text+'</div>';
- }else{
- output = '<div class="success">'+response.text+'</div>';
- $("#upload_form").slideUp(); //hide form after success
- }
- $("#upload_form").hide().html(output).slideDown();
- }, 'json');
- });
- });
- });
- </script>
- </head>
- <body>
- <h2>Hello <?php echo $user ?> </h2> <p> "You have successfully done purchasing process.</p>
- <div id="upload_form">
- <p>To send your size details for your order please upload the following file:</p>
- <p>Download custom size form Provide us your custom size: <a href="download.php?download_file=custom-measurement-form.pdf">File.pdf</a></p>
- <form enctype="multipart/form-data" action="" method="post">
- <input type="text" name="trxid" value="<?=$trx?>">
- <input type="text" name="orderid" value="<?=$orderid?>">
- <input type="text" name="custid" value="<?=$customerid?>">
- <input type="file" name="file">
- <input type="submit" id="submit_custom">
- </form>
- </div>
- </body>
- </html>
- <?php
- if(isset($_POST['file'])){
- if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
- $output = json_encode(array( //create JSON data
- 'type'=>'error',
- 'text' => 'Sorry Request must be Ajax POST'
- ));
- die($output);
- }
- $file=$_FILES['file']['name'];
- $trx=$_POST['trxid'];
- $oid=$_POST['orderid'];
- $cid=$_POST['custid'];
- echo $file;
- $query=mysqli_query($con,"insert into payments(custom_file) value ('$file') where orderid='$oid',trx_id='$trx' and cust_id='$cid' ");
- if($query){
- $m=move_uploaded_file($_FILES['file']['name'],'./ServerUploadedFiles/'.$trx.$file);
- $output = json_encode(array('type'=>'message', 'text' => 'Hi '.$user_name .' Thank you for your email'));
- die($output);
- }
- else
- {
- $output = json_encode(array('type'=>'error', 'text' => 'Problem uploading file! .'));
- die($output);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement