Need help.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jack
Forum Newbie
Posts: 3
Joined: Wed May 27, 2009 11:10 am

Need help.

Post by Jack »

Im new to programing and i decided to start with php.
I have been working on my first project but i reached a point in the project where im stuck.

When the user clicks on one link i want to be able to check and
see if there is another mp3 file in the ftp folder then start the next download
automatically and have it repeat the process until there are no
new file in the folder to download.

I know how to use loops so checking for the mp3 files should be easy,
but i need to know how to automatically start downloads.

Here's what i have so far.

CODE::
http://www.mediafire.com/download.php?cyjygjnmmdg

PAGE-EXAMPLE::
password= jack greg tod tom dog cat
[url]http://phpproject_001.t35.com/[/url]

I have no idea if my code is inefficient and i could use less code
to achieve what im doing or what.
Any help would be great.
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: Need help.

Post by mikemike »

You're being a little vague in your explanation, you've given us no or little idea what your project is and no code to go from.

If all you want to know if how to force a download on the browser then the answer is with header().

Code: Select all

 
$filename = 'myfile.mp3';
 
// Tell the browser what it is
header('Content-type: audio/mpeg');
 
// Force download
header('Content-Disposition: attachment; filename="'.$filename.'"');
Jack
Forum Newbie
Posts: 3
Joined: Wed May 27, 2009 11:10 am

Re: Need help.

Post by Jack »

That's what i was looking for.
Thanks for the help.
and
sorry for the confusing post.

What i'm trying to do is make a program that receives a password from a user
then checks to see if the password is one that is in the $pass array and what book it is
then displays the download page for that book.
And i needed help getting the download link on that page to download all 45 chapters
but have only one download link that needs to be clicked on.

Here is the code for the index page.

Code: Select all

<html>
<head>
<link rel="stylesheet" type="text/css" href="css\CssSheet.css" />
</head>
<body>
 
<center>
   <img src="img/Header.PNG" />
</center>
 
<div class="passbox">
 <br>
 <br>
 <center>
<form name="input" action="Pass_Check.php" method="post">
  <p>Type the password you recived at the end of your order.<br>
  <sub>Make sure that all letters are capitalized.</sub></p>
  <br> 
  <input type="text" name="password" size="20">
  <input type="submit" value="GO">
</forum>
 </center>
</div>
 
</body>
</html>
 
and the code for the password check.
I was thinking that there might be a easier way to check what book the
password is for.

Code: Select all

<?php
 
include ("Var_Start.php");
 
if(in_array($pass,$arr))
{
 while($looper==0)
 {
  if($pass==$arr[$a])
  {
  include ("Page_Display.php");
  $looper=1;
  }
  else
  {
  $a++;
  };
 };
}
else
{
print "PASSWORD NOT RECOGNIZED <br><br> Please use the back button and retype your password.<br>Make sure that all letters are capitalized.";
}
?>
This is the include ("Var_Start.php"); files code.

Code: Select all

<?php
$arr=array("jack","greg","tod","tom","dog","cat");
$pass=$_POST["password"];
$a=0;
$looper=0;
?>
and this is the include ("Page_Display.php"); files code

Code: Select all

<html>
<body>
<head>
<link rel="stylesheet" type="text/css" href="css\CssSheet.css" />
</head>
<body>
 
<div class="bookpage">
 
 <span class="linkstitle">
  <span class="title">
   <center>
   <?php
    include ("Render_Title.php");
   ?>
   </center>
  </span>
  <span class="links">
   <center>
   <?php
     include ("Render_Links.php");
   ?>
   </center>
  </span>
 </span>
 <br>
 <br>
 <span class="info">
 <hr>
  <center>
  <h3>:: Book Info ::</h3>
   <?php
    include ("Render_Info.php");
   ?>
  </center>
 
 </span>
 
</div>
</body>
</html>
The include ("Render_Links.php"), include ("Render_Title.php") and include ("Render_Info.php")
are just ifelse statements that check to see what password was submited and show the
book cover image, the books information and the books download links.

This is my first project other than doing basic if statements and having it print text if the condition was true.

Any help getting my code better organized or patching up security holes would be appreciated.
Jack
Forum Newbie
Posts: 3
Joined: Wed May 27, 2009 11:10 am

Re: Need help.

Post by Jack »

I have another question.
How can i tell when a download is done.
Is their some thing that sends a true/false 1/0 value back when the download is done??
User avatar
mikemike
Forum Contributor
Posts: 355
Joined: Sun May 24, 2009 5:37 pm
Location: Chester, UK

Re: Need help.

Post by mikemike »

No, not really. You may be able to use the new APC tools in 5.2>, but I really am unsure. You'll have to read the manual. I know it woks for uploads but I do doubt its the same for downloads.
Post Reply