Add success message sent to this script

How do i add a your request has been sent to the presenter to this script

request.php

<?php 
mysql_connect("","",""); 
//Change the above line 
mysql_select_db(""); 
//Change the above line 
$reg = "yes"; 
$ip = $_SERVER['REMOTE_ADDR']; 
?> 
<html> 
<head> 
<title>Request a song</title> 
</head> 
<body bgcolor="#DD0000">
<body> 
<center>
<?php 

if (isset($_POST['submit'])) { 
if (empty($_POST['song'])) { 
echo "Sorry, you haven't supplied the song title!<br />"; 
$reg = "no"; 
} 
if (empty($_POST['artist'])) { 
echo "Sorry, you haven't supplied the artists name!<br />"; 
$reg = "no"; 
} 
if (empty($_POST['name'])) { 
echo "Sorry, you haven't supplied your name<br />"; 
$reg = "no"; 
} 

  $sql = "SELECT COUNT(*) FROM request_song WHERE ip='{$ip}'"; 
  $result = mysql_query($sql); 
  if (mysql_result($result, 0) > 0) { 
echo "The Presenter is working on your previous request. <br /> Please try again soon. <br />"; 
$reg = "no"; 
} 
if ($reg == "yes") { 
    $sql = "INSERT INTO request_song(song, artist, name, ip) 
            VALUES('{$_POST['song']}', '{$_POST['artist']}', '{$_POST['name']}', '{$ip}')"; 
    mysql_query($sql); 
} 
} 
?> 
<form action="request.php" method="POST"> 
<table> 
<tr><td>Song title: </td><td><input type="text" name="song" value=""></td></tr> 
<tr><td>Artist: </td><td><input type="text" name="artist" value=""></td></tr> 
<tr><td>Your name: </td><td><input type="text" name="name" value=""></td></tr> 
</table> 
<input type="submit" name="submit" value="Send!"> 
</center>
</form> 
</body> 
</html>


**requested.php**


<?php 
mysql_connect("","",""); 
//Change the above line 
mysql_select_db(""); 
//Change the above line 

?> 
<html> 
<head> 
<title>Requested songs</title> 
</head> 
<body bgcolor="#919191">
    <center>
<body> 
<table width="600" border="1"> 
<tr><td>ID</td><td>Song</td><td>Artist</td><td>Requested by</td><td>Delete</td></tr> 
<?php 
if ($_GET['del']) { 
$delete = $_GET['del']; 
$delque = "DELETE FROM request_song WHERE id='{$delete}'";  
mysql_query($delque); 
} 
$query = "SELECT * FROM request_song ORDER BY id ASC";  
$result = mysql_query($query); 
while ($row = mysql_fetch_assoc($result)) { 
$id = $row['id']; 
$song = $row['song']; 
$artist = $row['artist']; 
$name = $row['name']; 
 
echo "<tr><td>".$id."</td><td>".$song."</td><td>".$artist."</td><td>".$name."</td><td><a href='?del=".$id."'>Delete</a></td></tr>"; 
} 
?> 
</center>
</table> 
</body> 
 <meta http-equiv="refresh" content="30">
 
</html>

Your code is dangerous, obsolete, and has been completely removed from PHP. You need to rewrite the script using PDO with Prepared Statements. This tutorial will get you going.
https://phpdelusions.net/pdo

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service