problem in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • niths
    New Member
    • Mar 2010
    • 18

    problem in php

    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...
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    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

    Comment

    • niths
      New Member
      • Mar 2010
      • 18

      #3
      Originally posted by dlite922
      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
      thanks for ur reply.
      here is my code.

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

      Code:
       <?php
      ob_start();
      @session_start();
      require_once ("check.php");
      include 'connection.php';
      $query= mysql_query("SELECT projectassign FROM projectassign where userid=(select userid from users where username='$username' and role='2')");
      mysql_error();
      $num=mysql_num_rows($query);  
       ?>
       <head>
       <link rel="stylesheet" type="text/css" href="style.css"/>
       <body>
       <script language="javascript" type="text/javascript">
              function check()
              {
                  if(document.getElementById('radio[]').value == "")
                  {
                      alert('Please select project');
                      return false;
                      
                  }
              }
              </script>
       <form action="upload.php" method="get">
       <table width="100%">
      <tr><td><img src="Logofinalcopy.gif">
      </td></tr></table><br><hr style="color: red;">
      <table align="right"><tr> <td></td>
              <td align="right" style="color: navy;"><strong><?php echo "Welcome ".$_SESSION[username];?>,</strong></td><td><a href="Logout.php">Logout</a></td>
          </tr></table>  
              
       <br><br>
       <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
       <tr>
       <th></th>
       <th style="color: navy;">Projectassign</th>
       </tr>
       <?php
           $sno=1;
          while($row=mysql_fetch_array($query, MYSQL_ASSOC)){
      ?>
       <tr>
          <td><input name="radio" type="radio" id="radio[]" checked="checked" value="<?php echo $row['projectassign'];?>"></td> 
          <td><?php echo $row['projectassign'];?></td>
       </tr>
       <?php
         $sno=$sno+1;   
      }
      ?>
       </table>
       <table align="center"><td align="center">
       <input type="submit" name="Submit"  value="Submit"></td>
       </table>
       </body></head>
      ------upload.php------

      Code:
      <html>
      <script language="javascript" type="text/javascript">
              function check()
              {
                  if(document.getElementById('file').value == "")
                  {
                      alert('Please select a file');
                      return false
                  }
              }
              //function MyReload()
              //{
              //    window.location.reload();
             // } 
               </script>        
      
      <body onload="MyReload()">
      <link rel="stylesheet" type="text/css" href="style.css"/>
      <form enctype="multipart/form-data" action="upload2.php" method="post">
      <table>
      <tr>
      <td><img src="Logofinalcopy.gif"></td>
      </tr>
      </table><br><hr style="color: red;">
      <table>
      <?php echo "<left> <br> <input type='button' value='back' onClick='history.go(-1)'></left>";
           $answer = $_GET['radio'];
           echo "<strong style='color:navy'>"."<center><h2> $answer  </h2></center>"."</strong>";
                    
           ?> 
      
      <tr>
      	<td style="color: navy;">
      		<strong>Please choose a file: </strong>
      	</td> 
      	<td>
      		<input id="file" name="uploaded" type="file"><br>
          </td>
      </tr>
      <tr><td>
      <input type="submit" value="upload" name="btn" onclick="return check()"></td></tr>
      </table>
           
      <?php
      ob_start();
      @session_start();
      require_once ("check.php");
      createsessions($username,$password,$userid,$projectid,$projectname,$filename,$size,$allocatedmemory,$answer,$usedmemory,$Remainingmemory,$result,$data3);
      include 'connection.php';
      
       $sql= "select * from files where uploadedby='$_SESSION[username]' and projectname='$_SESSION[answer]' ";
       mysql_error();
          $result=mysql_query($sql);
          $num=mysql_num_rows($result);
          $sql2="select allocatedmemory from projects where projectname='".$_SESSION[answer]."'"; 
          mysql_error();
          $d=mysql_query($sql2);
          $data1=mysql_result($d,0);?>
           <table><tr><td style="color: navy"><?php echo  " Allocated memory ".$data1;?></td></tr><br> 
          <?php
           $sql1="select sum(size) from files where projectname='$_SESSION[answer]'";
          mysql_error();
          $data=mysql_query($sql1);
          $usedmemory=mysql_result($data,0,"sum(size)");?>
          <tr><td style="color: navy"><?php echo "Used memory ".$usedmemory." kb"; ?></td></tr><br>
           <?php
          $data2=1024*$data1; 
           $data3=$data2-$usedmemory;?>
           <tr><td style="color: navy"><?php echo " Remaining memory ".$data3." kb";?></td></tr></table>
            <?php $answer = $_GET['radio'];                   
          ?>
      
      <table border="1" cellspacing="0" cellpadding="0" align="center" style="width: 500px" bordercolor="red">
      <tr>
      <th></th> 
      <th style="color: navy;">Fileid</th>
      <th style="color: navy;">Filename</th>
      <th style="color: navy;">Uploadedby</th>
      <th style="color: navy;">Uploadeddate(Y-M-D)</th>
      <th style="color: navy;">Size(in KB)</th>
      </tr>
       <?php
       $i=0;
      while ($i < $num) {
       $f=mysql_result($result,$i,"fileid");     
      $f1=mysql_result($result,$i,"filename");
      $f2=mysql_result($result,$i,"uploadedby");
      $f3=mysql_result($result,$i,"uploadeddate");
      $f4=mysql_result($result,$i,"size");
                                   
      ?>
       <tr>
       <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')">
          download</a></td>
      <td><?php echo $f;?></td>
      <td><?php echo $f1;?></td> 
      <td><?php echo $f2; ?></td>
      <td><?php echo $f3;?></td>
      <td><?php echo $f4; ?> </td>
      <!--<td><input type="submit" name="btn" value="Delete"</td>--></tr>
      <?php
          $i++;
          }
      ?>
      </table>
      </form></body></html>
      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...

      Comment

      Working...