Song requests

Joined
Jun 14, 2018
Messages
109
Reaction score
1
hey! i'v got this script from chatgpt

Code:
<!DOCTYPE html>
<html>
<head>
    <title>Song Requests and Dedications</title>
</head>
<body>
    <h1>Song Requests and Dedications</h1>
    <p>Select a song from the list below to make a request or dedication:</p>
    
    <ul id="song-list">
        <li><a href="#" onclick="requestSong('Song Title 1', 'Artist 1')">All The Lovers - Kylie Minogue</a></li>
        <li><a href="#" onclick="requestSong('Song Title 2', 'Artist 2')">Breathe - Kylie Minogue</a></li>
        <li><a href="#" onclick="requestSong('Song Title 3', 'Artist 3')">in you're eyes - Kylie Minogue</a></li>
        <li><a href="#" onclick="requestSong('Song Title 4', 'Artist 4')">Years & Years - Kylie Minogue</a></li>
        <li><a href="#" onclick="requestSong('Song Title 5', 'Artist 5')">Heaven - Belinda Carlisle</a></li>
        <li><a href="#" onclick="requestSong('Song Title 6', 'Artist 6')">sweet sixteen - billy idol</a></li>
        <li><a href="#" onclick="requestSong('Song Title 7', 'Artist 4')">when the going gets tough - billy ocean</a></li>
    </ul>
    
    <h2>Make a Request or Dedication</h2>
    <form id="song-request-form">
        <label for="name">Your Name:</label><br>
        <input type="text" id="name" required><br><br>
        
        <label for="message">Dedication Message:</label><br>
        <textarea id="message" rows="4" cols="50"></textarea><br><br>
        
        <button type="button" onclick="submitRequest()">Submit Request</button>
    </form>
    
    <p id="confirmation-message"></p>
    
    <script>
        function requestSong(songTitle, artistName) {
            document.getElementById("song-request-form").style.display = "block";
            document.getElementById("song-title").textContent = songTitle;
            document.getElementById("artist-name").textContent = artistName;
        }
        
        function submitRequest() {
            var name = document.getElementById("name").value;
            var songTitle = document.getElementById("song-title").textContent;
            var artistName = document.getElementById("artist-name").textContent;
            var message = document.getElementById("message").value;
            
            if (name !== "") {
                var confirmation = "Request received! Thank you, " + name + ", for requesting \"" + songTitle + "\" by " + artistName + ".";
                if (message !== "") {
                    confirmation += " Your dedication message: \"" + message + "\"";
                }
                document.getElementById("confirmation-message").textContent = confirmation;
                clearForm();
            } else {
                alert("Please enter your name before submitting.");
            }
        }
        
        function clearForm() {
            document.getElementById("name").value = "";
            document.getElementById("message").value = "";
        }
    </script>
</body>
</html>

it wants me to enter links with every song?
where am i supposed to get links from, so that the script can work, i'm NOT using youtube or spotify lol
 
Joined
Jul 4, 2023
Messages
475
Reaction score
58
You should try code similar to this


HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Song Requests and Dedications</title>

    <style>
      input[type="radio"] {
        display: none;
      }
      label,
      button {
        display: block;
        margin: .75rem 0 .2rem;
      }
      input[type="radio"] + label {
        user-select: none;
        cursor: pointer;
      }
      input[type="radio"]:checked + label {
        font-weight: bold;
      }
      li:has(input[type="radio"]:checked) {
        list-style-type: "+  ";
      }
      pre {
        color: red;
      }
    </style>
  </head>
  <body>
    <h1>Song Requests and Dedications</h1>
    <p>Select a song from the list below to make a request or dedication:</p>

    <form action="song_request_dedication.php" method="post" id="song-request-dedication-form" onsubmit="submitRequest(event)">
      <ul id="song-list">
        <li>
          <input type="radio" id="song-1" name="song" value="put link to the song-1">
          <label for="song-1">All The Lovers - Kylie Minogue</label>           
        </li>
        <li>
          <input type="radio" id="song-2" name="song" value="put link to the song-2">
          <label for="song-2">Breathe - Kylie Minogue</label>           
        </li>       
        <li>
          <input type="radio" id="song-3" name="song" value="put link to the song-3">
          <label for="song-3">In you're eyes - Kylie Minogue</label>           
        </li> 
        <li>
          <input type="radio" id="song-4" name="song" value="put link to the song-4">
          <label for="song-4">Years & Years - Kylie Minogue</label>           
        </li>
        <li>
          <input type="radio" id="song-5" name="song" value="put link to the song-5">
          <label for="song-5">Heaven - Belinda Carlisle</label>           
        </li>
        <li>
          <input type="radio" id="song-6" name="song" value="put link to the song-6">
          <label for="song-6">Sweet sixteen - Billy Idol</label>           
        </li>
        <li>
          <input type="radio" id="song-7" name="song" value="put link to the song-7">
          <label for="song-7">When the going gets tough - Billy Ocean</label>           
        </li>       
      </ul>

      <h2>Make a Request or Dedication</h2>

      <label for="name">Your Name:</label>
      <input type="text" id="name" name="name" required>

      <label for="message">Dedication Message:</label>
      <textarea id="message" name="message" rows="4" cols="50" required></textarea>

      <pre id="confirmation-message"></pre>

      <button type="submit">Submit Request</button>
    </form>

    <script>
      function submitRequest(e) {
        const song = document.querySelector('input[type="radio"]:checked');
        const name = document.getElementById('name').value;
        const message = document.getElementById('message').value;
        const confirmation = document.getElementById('confirmation-message');

        e.preventDefault();
        confirmation.textContent = '';

        if (!song)
          confirmation.textContent += 'Select a song before submitting.\n';
        if (!name)
          confirmation.textContent += 'Please enter your name before submitting.\n';
        if (!message)
          confirmation.textContent += 'Please enter message before submitting.\n';
        if (song && name && message)
          document.getElementById('song-request-dedication-form').submit();
      }
    </script>
  </body>
</html>
 
Joined
Jun 14, 2018
Messages
109
Reaction score
1
You should try code similar to this


HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Song Requests and Dedications</title>

    <style>
      input[type="radio"] {
        display: none;
      }
      label,
      button {
        display: block;
        margin: .75rem 0 .2rem;
      }
      input[type="radio"] + label {
        user-select: none;
        cursor: pointer;
      }
      input[type="radio"]:checked + label {
        font-weight: bold;
      }
      li:has(input[type="radio"]:checked) {
        list-style-type: "+  ";
      }
      pre {
        color: red;
      }
    </style>
  </head>
  <body>
    <h1>Song Requests and Dedications</h1>
    <p>Select a song from the list below to make a request or dedication:</p>

    <form action="song_request_dedication.php" method="post" id="song-request-dedication-form" onsubmit="submitRequest(event)">
      <ul id="song-list">
        <li>
          <input type="radio" id="song-1" name="song" value="put link to the song-1">
          <label for="song-1">All The Lovers - Kylie Minogue</label>          
        </li>
        <li>
          <input type="radio" id="song-2" name="song" value="put link to the song-2">
          <label for="song-2">Breathe - Kylie Minogue</label>          
        </li>      
        <li>
          <input type="radio" id="song-3" name="song" value="put link to the song-3">
          <label for="song-3">In you're eyes - Kylie Minogue</label>          
        </li>
        <li>
          <input type="radio" id="song-4" name="song" value="put link to the song-4">
          <label for="song-4">Years & Years - Kylie Minogue</label>          
        </li>
        <li>
          <input type="radio" id="song-5" name="song" value="put link to the song-5">
          <label for="song-5">Heaven - Belinda Carlisle</label>          
        </li>
        <li>
          <input type="radio" id="song-6" name="song" value="put link to the song-6">
          <label for="song-6">Sweet sixteen - Billy Idol</label>          
        </li>
        <li>
          <input type="radio" id="song-7" name="song" value="put link to the song-7">
          <label for="song-7">When the going gets tough - Billy Ocean</label>          
        </li>      
      </ul>

      <h2>Make a Request or Dedication</h2>

      <label for="name">Your Name:</label>
      <input type="text" id="name" name="name" required>

      <label for="message">Dedication Message:</label>
      <textarea id="message" name="message" rows="4" cols="50" required></textarea>

      <pre id="confirmation-message"></pre>

      <button type="submit">Submit Request</button>
    </form>

    <script>
      function submitRequest(e) {
        const song = document.querySelector('input[type="radio"]:checked');
        const name = document.getElementById('name').value;
        const message = document.getElementById('message').value;
        const confirmation = document.getElementById('confirmation-message');

        e.preventDefault();
        confirmation.textContent = '';

        if (!song)
          confirmation.textContent += 'Select a song before submitting.\n';
        if (!name)
          confirmation.textContent += 'Please enter your name before submitting.\n';
        if (!message)
          confirmation.textContent += 'Please enter message before submitting.\n';
        if (song && name && message)
          document.getElementById('song-request-dedication-form').submit();
      }
    </script>
  </body>
</html>
thank you so i'v designed this code for the php page
Code:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Retrieve the form data
    $selectedSong = $_POST["song"];
    $name = $_POST["name"];
    $message = $_POST["message"];

    // Perform any necessary processing (e.g., storing in a database, sending emails)
    
    // Return a response (e.g., success or error message)
    echo "Request submitted successfully!";
} else {
    echo "Invalid request.";
}
?>

but when i test the form at https://coolvibes-reloaded.com/reqjay.html i test the form
press submit i get

This page isn’t working​

If the problem continues, contact the site owner.


HTTP ERROR 405


what am i doing wrong?
 
Joined
Jul 4, 2023
Messages
475
Reaction score
58
Click on this link

and you'll see what happen. You need install or you need to enable php support on your server.
Now the php file is treated like any normal file that can be downloaded, not a php code file that should only run server side
 
Joined
Jun 14, 2018
Messages
109
Reaction score
1
Click on this link

and you'll see what happen. You need install or you need to enable php support on your server.
Now the php file is treated like any normal file that can be downloaded, not a php code file that should only run server side
ok thank you, second question i'm trying to send song requests from a google form to my facebook page?

now i've created this script
Code:
function postSongRequestToFacebook(dj, artistname, artistsong, yourname, yourdedication, funnysadmoments) {
  var pageAccessToken = 'EAAIv6I8lnjkBO0nSjyNtJpU4ay6taqDLLRiqOzcLavttiBgsSoOZCAAYuDk5YQHjUb5IvNWZAQ08ZBnZBEMDEvcjJkJwlIcPlQKC7uMu1GoSgNgiWapMxIUjcr4CJMWWbICfTTdlRUtiw8tKfosPlvNawzny161sYVCWLxRgandQhxCRF13Uh4qqr1KmmyW9bLyzD618GwmOTzBob0dM3Ntg';
  var pageId = '2301093033279315'; // Replace with your page's ID
  var message = 'New song request: ' + dj + ', ' + artistname + ', ' + artistsong + ', ' + yourname + ' - Dedication: ' + yourdedication + ' - ' + funnysadmoments;
  var url = 'https://graph.facebook.com/' + 2301093033279315 + '/feed';
  var payload = {
    method: 'post',
    contentType: 'application/x-www-form-urlencoded',
    payload: 'access_token=' + pageAccessToken + '&message=' + encodeURIComponent(message)
  };
  var response = UrlFetchApp.fetch(url, payload);
  var responseData = JSON.parse(response.getContentText());
  if (responseData.id) {
    Logger.log('Song request posted successfully');
  } else {
    Logger.log('Error posting song request');
    Logger.log(responseData.error);
  }
}

but every time i test the requests i cannot see the posted requests on my facebook page?

i can't for my life figure out why it's not happening
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top