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
https://forums.phpfreaks.com/topic/38365-solved-help-with-php-page/
Share on other sites

I'd point you to many of the fine tutorials here at PHPFreaks as well as others you can learn the basics from for free all around the web. Plus, there's always the official PHP site at www.php.net 

 

There's some great mini-tutorials and basics on both PHP and MySQL here: http://www.w3schools.com/php/default.asp

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. ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.