By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,968 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,968 IT Pros & Developers. It's quick & easy.

problem in php

P: 18
hi all,
i am having a problem. i had a projects page and list of projects can be seen with radio buttons. so wen we select a project and click submit we go to the upload page and the value of radio button is send to upload page by url. so wen i upload a file it wil be displayed in a table with each having download link so here is my problem wen i click on the download link popup comes and the value which i am getting by 'url' is refreshing.I want those values remain as it is wen i click download link. Thank u...
May 12 '10 #1
Share this Question
Share on Google+
2 Replies


dlite922
Expert 100+
P: 1,584
Where is the code that is giving you trouble.

I just have a vague idea of what your program is trying to do, need more info.





Dan
May 12 '10 #2

P: 18
@dlite922
thanks for ur reply.
here is my code.

------User.php------

Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. ob_start();
  3. @session_start();
  4. require_once ("check.php");
  5. include 'connection.php';
  6. $query= mysql_query("SELECT projectassign FROM projectassign where userid=(select userid from users where username='$username' and role='2')");
  7. mysql_error();
  8. $num=mysql_num_rows($query);  
  9.  ?>
  10.  <head>
  11.  <link rel="stylesheet" type="text/css" href="style.css"/>
  12.  <body>
  13.  <script language="javascript" type="text/javascript">
  14.         function check()
  15.         {
  16.             if(document.getElementById('radio[]').value == "")
  17.             {
  18.                 alert('Please select project');
  19.                 return false;
  20.  
  21.             }
  22.         }
  23.         </script>
  24.  <form action="upload.php" method="get">
  25.  <table width="100%">
  26. <tr><td><img src="Logofinalcopy.gif">
  27. </td></tr></table><br><hr style="color: red;">
  28. <table align="right"><tr> <td></td>
  29.         <td align="right" style="color: navy;"><strong><?php echo "Welcome ".$_SESSION[username];?>,</strong></td><td><a href="Logout.php">Logout</a></td>
  30.     </tr></table>  
  31.  
  32.  <br><br>
  33.  <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
  34.  <tr>
  35.  <th></th>
  36.  <th style="color: navy;">Projectassign</th>
  37.  </tr>
  38.  <?php
  39.      $sno=1;
  40.     while($row=mysql_fetch_array($query, MYSQL_ASSOC)){
  41. ?>
  42.  <tr>
  43.     <td><input name="radio" type="radio" id="radio[]" checked="checked" value="<?php echo $row['projectassign'];?>"></td> 
  44.     <td><?php echo $row['projectassign'];?></td>
  45.  </tr>
  46.  <?php
  47.    $sno=$sno+1;   
  48. }
  49. ?>
  50.  </table>
  51.  <table align="center"><td align="center">
  52.  <input type="submit" name="Submit"  value="Submit"></td>
  53.  </table>
  54.  </body></head>
  55.  
  56.  
------upload.php------

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <script language="javascript" type="text/javascript">
  3.         function check()
  4.         {
  5.             if(document.getElementById('file').value == "")
  6.             {
  7.                 alert('Please select a file');
  8.                 return false
  9.             }
  10.         }
  11.         //function MyReload()
  12.         //{
  13.         //    window.location.reload();
  14.        // } 
  15.          </script>        
  16.  
  17. <body onload="MyReload()">
  18. <link rel="stylesheet" type="text/css" href="style.css"/>
  19. <form enctype="multipart/form-data" action="upload2.php" method="post">
  20. <table>
  21. <tr>
  22. <td><img src="Logofinalcopy.gif"></td>
  23. </tr>
  24. </table><br><hr style="color: red;">
  25. <table>
  26. <?php echo "<left> <br> <input type='button' value='back' onClick='history.go(-1)'></left>";
  27.      $answer = $_GET['radio'];
  28.      echo "<strong style='color:navy'>"."<center><h2> $answer  </h2></center>"."</strong>";
  29.  
  30.      ?> 
  31.  
  32. <tr>
  33.     <td style="color: navy;">
  34.         <strong>Please choose a file: </strong>
  35.     </td> 
  36.     <td>
  37.         <input id="file" name="uploaded" type="file"><br>
  38.     </td>
  39. </tr>
  40. <tr><td>
  41. <input type="submit" value="upload" name="btn" onclick="return check()"></td></tr>
  42. </table>
  43.  
  44. <?php
  45. ob_start();
  46. @session_start();
  47. require_once ("check.php");
  48. createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result,$data3);
  49. include 'connection.php';
  50.  
  51.  $sql= "select * from files where uploadedby='$_SESSION[username]' and projectname='$_SESSION[answer]' ";
  52.  mysql_error();
  53.     $result=mysql_query($sql);
  54.     $num=mysql_num_rows($result);
  55.     $sql2="select allocatedmemory from projects where projectname='".$_SESSION[answer]."'"; 
  56.     mysql_error();
  57.     $d=mysql_query($sql2);
  58.     $data1=mysql_result($d,0);?>
  59.      <table><tr><td style="color: navy"><?php echo  " Allocated memory ".$data1;?></td></tr><br> 
  60.     <?php
  61.      $sql1="select sum(size) from files where projectname='$_SESSION[answer]'";
  62.     mysql_error();
  63.     $data=mysql_query($sql1);
  64.     $usedmemory=mysql_result($data,0,"sum(size)");?>
  65.     <tr><td style="color: navy"><?php echo "Used memory ".$usedmemory." kb"; ?></td></tr><br>
  66.      <?php
  67.     $data2=1024*$data1; 
  68.      $data3=$data2-$usedmemory;?>
  69.      <tr><td style="color: navy"><?php echo " Remaining memory ".$data3." kb";?></td></tr></table>
  70.       <?php $answer = $_GET['radio'];                   
  71.     ?>
  72.  
  73. <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
  74. <tr>
  75. <th></th> 
  76. <th style="color: navy;">Fileid</th>
  77. <th style="color: navy;">Filename</th>
  78. <th style="color: navy;">Uploadedby</th>
  79. <th style="color: navy;">Uploadeddate(Y-M-D)</th>
  80. <th style="color: navy;">Size(in KB)</th>
  81. </tr>
  82.  <?php
  83.  $i=0;
  84. while ($i < $num) {
  85.  $f=mysql_result($result,$i,"fileid");     
  86. $f1=mysql_result($result,$i,"filename");
  87. $f2=mysql_result($result,$i,"uploadedby");
  88. $f3=mysql_result($result,$i,"uploadeddate");
  89. $f4=mysql_result($result,$i,"size");
  90.  
  91. ?>
  92.  <tr>
  93.  <td><a href =http://localhost/Project/upload.php onclick="window.open('http://localhost/Project/download.php?f1=<?php echo $f1;?>','popup','width=550,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=center,menubar=no,status=no,left=370,center=0,top=300')">
  94.     download</a></td>
  95. <td><?php echo $f;?></td>
  96. <td><?php echo $f1;?></td> 
  97. <td><?php echo $f2; ?></td>
  98. <td><?php echo $f3;?></td>
  99. <td><?php echo $f4; ?> </td>
  100. <!--<td><input type="submit" name="btn" value="Delete"</td>--></tr>
  101. <?php
  102.     $i++;
  103.     }
  104. ?>
  105. </table>
  106. </form></body></html> 
  107.  
I am getting the radio button value from User.php page to upload.php. By using get method. I just got one idea i am getting the value through form, instead of doing like that cant we keep the '$radio' in session so that even refreshed the value remains same. But i am not getting it. so can any one...
May 13 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.