Jump to content

[SOLVED] Help with php page


steviez

Recommended Posts

Hi,

 

I run a music website for new bands, i want to be able to give them the option to allow their mp3 to be downloaded free. I only want the download link to apear on listen.php if the user has specified allow downloads in myaudio.php. It needs to pull the song info from the "audio" database.

 

Any ideAs as i am stuck

 

Thanks

Link to comment
Share on other sites

To give you a rough outline of what you can do, first you can create a field in the specified table called 'allow_free_mp3' (or whatever you want) and on myaudio.php, have a form with 'yes' or 'no' options and have that inserted into the field:

 

myaudio.php

<form action="myaudio.php" method="post">
Allow free MP3s to be downloaded?
<select name="allowfree">
  <option value="yes">Yes</option>
  <option value="no">No</option>
</select> 
<input name="update" type="submit" value="Update" />
</form>

<?php
if ($_POST['update']) {
   // Connect to your database.
   mysql_query('INSERT INTO table_name (allow_free_mp3) VALUES ('.$_POST['allowfree'].')') or die (mysql_error());
}
?>

 

listen.php

<?php
$allowquery = mysql_query('SELECT allow_free_mp3 FROM table_name /* Specify WHERE options */');
$row = mysql_fetch_array($allowquery);
if ($row['allow_free_mp3'] == 'yes') {
  // Your code when free MP3 downloading is allowed.
} else {
 // Your code when free MP3 downloading is NOT allowed.
}
?>

 

It isn't that great, but it's a start. If you want to know about using MySQL with PHP, just searh Google. ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.