Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" </script>
  4. <script type="text/javascript">
  5. $(document).ready(function() {
  6. $("#submit_custom").click(function() {
  7. var proceed = true;
  8. $("#upload_form input[required=true]").each(function(){
  9. $(this).css('border-color','');
  10. if(!$.trim($(this).val())){ //if this field is empty
  11. $(this).css('border-color','red'); //change border color to red
  12. proceed = false; //set do not proceed flag
  13. }
  14. if(proceed)
  15. post_data = {
  16. 'file': $('input[name=file]').val(),
  17. 'trxid': $('input[name=trxid]').val(),
  18. 'orderid': $('input[name=orderid]').val(),
  19. 'custid': $('input[name=custid]').val()
  20.  
  21. };
  22. $.post('upload.php', post_data, function(response){
  23. if(response.type == 'error'){ //load json data from server and output message
  24. output = '<div class="error">'+response.text+'</div>';
  25. }else{
  26. output = '<div class="success">'+response.text+'</div>';
  27. $("#upload_form").slideUp(); //hide form after success
  28. }
  29. $("#upload_form").hide().html(output).slideDown();
  30. }, 'json');
  31. });
  32. });
  33. });
  34. </script>
  35. </head>
  36. <body>
  37. <h2>Hello <?php echo $user ?> </h2> <p> "You have successfully done purchasing process.</p>
  38. <div id="upload_form">
  39. <p>To send your size details for your order please upload the following file:</p>
  40. <p>Download custom size form Provide us your custom size: <a href="download.php?download_file=custom-measurement-form.pdf">File.pdf</a></p>
  41. <form enctype="multipart/form-data" action="" method="post">
  42. <input type="text" name="trxid" value="<?=$trx?>">
  43. <input type="text" name="orderid" value="<?=$orderid?>">
  44. <input type="text" name="custid" value="<?=$customerid?>">
  45. <input type="file" name="file">
  46. <input type="submit" id="submit_custom">
  47. </form>
  48. </div>
  49. </body>
  50. </html>
  51.  
  52. <?php
  53. if(isset($_POST['file'])){
  54. if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
  55. $output = json_encode(array( //create JSON data
  56. 'type'=>'error',
  57. 'text' => 'Sorry Request must be Ajax POST'
  58. ));
  59. die($output);
  60. }
  61. $file=$_FILES['file']['name'];
  62. $trx=$_POST['trxid'];
  63. $oid=$_POST['orderid'];
  64. $cid=$_POST['custid'];
  65. echo $file;
  66.  
  67. $query=mysqli_query($con,"insert into payments(custom_file) value ('$file') where orderid='$oid',trx_id='$trx' and cust_id='$cid' ");
  68. if($query){
  69. $m=move_uploaded_file($_FILES['file']['name'],'./ServerUploadedFiles/'.$trx.$file);
  70. $output = json_encode(array('type'=>'message', 'text' => 'Hi '.$user_name .' Thank you for your email'));
  71. die($output);
  72. }
  73. else
  74. {
  75. $output = json_encode(array('type'=>'error', 'text' => 'Problem uploading file! .'));
  76. die($output);
  77. }
  78. }
  79.  
  80. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement