Advertisement
Sonic3R

english_textarea_trouble

Aug 6th, 2011
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.38 KB | None | 0 0
  1. /* HTML code */
  2. Filename with extension :
  3. <input type="text" placeholder="ex: test.css" id="titlecopypaste" /><br/>
  4. <textarea cols="60" rows="10" placeholder="Insert code here" id="content"></textarea><br/>
  5. <select id="choose">
  6. <option value="public" selected="selected">Public</option>
  7. <option value="private">private</option>
  8. <option value="both">Public si private</option>
  9. </select>
  10. <center><button id="submitcopypaste">Done</button><br/>
  11. <p id="status_create"></p>
  12. </center>
  13.  
  14.  
  15.  
  16.  
  17. /* Javascript code */
  18. $("#submitcopypaste").click(function()
  19. {
  20.     var fisier=$("#titlecopypaste").val();
  21.     var content=$("#content").text();
  22.     var select=$("#choose").val();
  23.     $.ajax({
  24.         type:"POST",
  25.         url:"include/uploadtxt.php",
  26.         data:"fis="+fisier+"&cont="+content+"&sel="+select,
  27.         success:function(ev)
  28.         {
  29.             $(this).hide();
  30.             $("#status_create").html(ev);
  31.         }
  32. });
  33.  
  34.  
  35.  
  36.  
  37.  
  38. /* PHP code */
  39. session_start();
  40. include('Files.php'); //the class created by
  41. include('connect.php');
  42. $status="";
  43. if(isset($_POST['fis'],$_POST['cont'],$_POST['sel']))
  44.     {
  45.         $obj=new Files();
  46.         $file=$_POST['fis'];
  47.         $content=$_POST['cont'];
  48.         $selected=$_POST['sel'];
  49.        
  50.         switch($selected)
  51.             {
  52.             case "public":{
  53.                 $status=$obj->createfile("../diskuser/_public/".$file, $content);break;
  54.             }
  55.             case "private":{
  56.                 if(isset($_SESSION['utilizator'],$_SESSION['parola']))
  57.                     {
  58.                 $cer=mysql_query("select * from user where nickname='".$_SESSION['user']."' and password='".$_SESSION['parola']."'");
  59.                 if($cer)
  60.                     {
  61.                         while($info=mysql_fetch_array($cer))
  62.                             {
  63.                                 $status=$obj->createfile("../diskuser/".$info['nickname']."/".$file, $content);break;
  64.                             }
  65.                     }
  66.                 else
  67.                     {
  68.                         $status="Connection error!";
  69.                     }
  70.                     }
  71.                 else
  72.                     {
  73.                         $status="The session has been expired !";
  74.                     }
  75.                     break;
  76.             }
  77.             case "both":{
  78.                 $status=$obj->createfile("../diskuser/_public/".$file, $content);
  79.                 $cer=mysql_query("select * from user where nickname='".$_SESSION['user']."' and password='".$_SESSION['parola']."'");
  80.                 if($cer)
  81.                     {
  82.                         while($info=mysql_fetch_array($cer))
  83.                             {
  84.                                 $status=$obj->createfile("../diskuser/".$info['nickname']."/".$file, $content);break;
  85.                             }
  86.                     }
  87.                 else
  88.                     {
  89.                         $status="Database connection error !";
  90.                     }
  91.                     break;
  92.             }
  93.             }
  94.     }
  95. else
  96.     {
  97.         $status="Invalid data !";
  98.     }
  99.     echo $status;
  100.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement