I’m trying to write songs to a text file and then be able to add/delete, shuffle etc within that text file.
I’m having an issue with ending my first “IF” statement. Here is what I get they way it is currently written —
You are viewing this page because you have submitted a song to our list
You have not entered a song, please use link below and enter a song
“; die (); } has been added to Duff’sSong list!
You have add a song.
To go back to the main menu Click Here
Here is my HTML front end —
[code=html]
<html>
<title> Welcome to Duff’s Songs Inventory </title>
<h1></center><head> Congrats, now that you are here you are able to add songs to your inventory list! </head></center></h1>
<body>
<center>
<form action = “m5donovanCP7-2.php” method = “post”>
<p><a href=”m5donovanCP7-2.php”>View List</a> <a href = “m5donovanCP7-2.php”>Sort By Name</a> <a href = “m5donovanCP7-2.php”>Shuffle Songs</a>
<br />
<br />
<input type = “text” name = “song” size = “25”>
<input type = “submit” value = “Add Song”>
</form>
</center>
</body>
</html>
Here is the PHP code: This has the area that should be accepting the new song and writing it to the text file, which it currently isn’t doing
[code=php]
<html>
<title> Welcome to Duff’s Songs Inventory </title>
<h2><center><head> You are viewing this page because you have submitted a song to our list</head></center></h2>
<body>
<?php
if (empty($_REQUEST[‘song’]) {
print “<p>You have not entered a song, please use link below and enter a song</p>”;
die ();
}
<?php print (“{$_REQUEST[‘song’]}”); ?> has been added to Duff’sSong list!
<?php
if (file_exists(“Duff’sSongs.txt”) && filesize (“Duff’sSongs.txt”) ! =0) {
}
$file = “Duffs’sSong.txt”;
$duffsHandle = fopen($file, ‘a+’);
$song = (“{$_REQUEST[‘song’]}”);
fwrite = ($duffsHandle, $song);
fclose ($duffsHandle);
?>
<p>You have add a song. </p> <br />
<p> To go back to the main menu <a href = m5donovanCP7-2.html>Click Here</a>
</body>
</html>