Jump to content

If statement not loading


ChrisMartino

Recommended Posts

Ok so i did something last night and i cant seem to fix it when i load track.php the page is empty just the site theme empty content, But track.php?song=(songid) works? can anyone help me out:

 

<?php include "Main/Database/base.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta name="Description" content="Information architecture, Web Design, Web Standards." />
<meta name="Keywords" content="your, keywords" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="Distribution" content="Global" />
<meta name="Author" content="Erwin Aligam - ealigam@gmail.com" />
<meta name="Robots" content="index,follow" />

<link rel="stylesheet" href="images/MarketPlace.css" type="text/css" />

<LINK REL="SHORTCUT ICON"
       HREF="favicon.ico">

<title>Musicians Village - <?=$_SESSION['Username']?>'s Profile</title>

</head>

<body>

<!-- wrap starts here -->
<div id="wrap">

<!--header -->
<div id="header">			

	<div id="header-links">
	<p>
	<?php
		if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
		{
 	?>
    				<p>Logged in as: <a href="profile.php"><b><?=$_SESSION['Username']?></a></b> | Account: <?=$_SESSION['AccountType']?> | <a href="logout.php">Logout</a> </p>

	<?php
		}
		else
		{
	?>
			<p>Welcome <b>Guest</b>, Please <a href="login.php">Login</a> or <a href="register.php">Register</a></p>
	<?php
		}
	?>

    

	</p>		
	</div>		

<!--header ends-->					
</div>

<div id="header-photo"></div>		

<!-- navigation starts-->	
<div  id="nav">
	<ul>
		<li><a href="index.php">Home</a></li>
		<li><a href="login.php">Login</a></li>
		<li><a href="register.php">Register</a></li>			
		<li><a href="track.php?action=upload">Submit Track</a></li>
		<li><a href="track.php?action=listen">Listen To Tracks</a></li>
		<li><a href="/forums">Forums</a></li>
		<li><a href="contact.php">Contact</a></li>		
	</ul>
<!-- navigation ends-->	
</div>					

<!-- content-wrap starts -->
<div id="content-wrap" class="three-col"  >	

	<div id="sidebar">


		<h1>Sponsors</h1>
		<ul class="sidemenu">				
			<li><a href="index.html">Home</a></li>
			<li><a href="#TemplateInfo">Template Info</a></li>
			<li><a href="#SampleTags">Sample Tags</a></li>
			<li><a href="http://www.styleshout.com/">More Free Templates</a></li>	
			<li><a href="http://www.4templates.com/?aff=ealigam">Premium Templates</a></li>	
		</ul>	


	<!-- sidebar ends -->		
	</div>

	<div id="rightcolumn">

		<h1>Forum Stats</h1>
		<p>Top poster stuff here</p>

		<h1>*Newest track</h1>
		<p>it is here too! </p>				

	</div>


	<div id="main">
	<p>

				<?php
			if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))
			{	

					// The veriables, Including the sessions.
					$Administrator = "Administrator";
					$AccountQurey = $_SESSION['AccountType'];

					$User = $_SESSION['Username'];
					$Email = $_SESSION['EmailAddress'];
					$AccTyp = $_SESSION['AccountType'];
					$AccountIP = $_SESSION['AccountIP'];


					$action = $_GET['action'];
					$Song = $_GET['song'];
					$Upload = "upload";
					$Password = "password";

					?>


					<?php
					if ($action == "" && $Song = "") {
					?>
						<h1>Upload a Track</h1>
						<form action="track.php?action=upload" method="post" enctype="multipart/form-data">
						   <p>
							  <label for="SongName">Track Name:</label><input type="text" name="SongName" id="SongName" /><br />
							  <label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
							  <p><b><a href="tos.php">Before uploading you must agree to our TOS</a></b></p>
							  <button>Upload Track</button>
						   <p>
						</form>
					<?php
					}
					elseif($action == $Upload)
					{

							$FileCheck = "/home/chrismar/public_html/Websites/Music/Songs/$User";

							if (file_exists($FileCheck)) {

											  // Configuration - Your Options
								  $allowed_filetypes = array('.mp3','.wma','.bmp','.png'); // These will be the types of file that will pass the validation.
								  $max_filesize = 52428888; // Maximum filesize in BYTES (currently 0.5MB).
								  $upload_path = "/home/chrismar/public_html/Websites/Music/Songs/$User/"; // The place the files will be uploaded to (currently a 'files' directory).
								  $HTTPath = "Songs/$User";

								  $CheckFileName = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
								  $filename = str_replace(' ', '_', $CheckFileName);
								  $ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////		Checking the file size's and if the path is writable.		/////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////

									 // Check if we can upload to the specified path, if not DIE and inform the user.
									if(!is_writable($upload_path))
										die('You cannot upload to the specified directory, please CHMOD it to 777.');

									// Now check the filesize, if it is too large then DIE and inform the user.
									if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
										die('The file you attempted to upload is too large.');

									// Check if the filetype is allowed, if not DIE and inform the user.
									if(!in_array($ext,$allowed_filetypes))
										die('The file you attempted to upload is not allowed.');

									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////		If there is no errors above echo the information			/////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									/////////////////////////////////////////////////////////////////////////////////////////////////////////////
									   // Upload the file to your specified path.
									if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
									{
											$SongName = mysql_real_escape_string($_POST['SongName']);
											$SongAuthour = mysql_real_escape_string($_SESSION['Username']);
											$SongDIRR = "http://chrismartino.x10hosting.com/Websites/Music/Songs/$User/$filename";
											$SongDIR = mysql_real_escape_string($SongDIRR);


											$TrackQuery = mysql_query("INSERT INTO TrackUploads (TrackAuthor, TrackUrl, TrackName) VALUES('".$SongAuthour."', '".$SongDIR."', '".$SongName."')");

											$SongQurey = mysql_query("SELECT * FROM TrackUploads WHERE TrackUrl = '".$SongDIR."'");

											$row = mysql_fetch_array($SongQurey);
											$SongID = $row['id'];

											echo "<h1>Success</h1>";
											echo "<p>You have successfully uploaded your track!, You can listen to it <a href=\"track.php?song=$SongID\">Here</a>.</p>";
									}
									else
									{
										 echo 'There was an error during the file upload.  Please try again.'; // It failed .
									}
							}
							else
							{
								mkdir($FileCheck, 0777);
							}



					}
					elseif(isset($_GET['song']))
					{
						if(is_numeric($_GET['song']))
						{
							// get the member id
							$memberID = (int) $_GET['song'];

							$memberIDinfo = mysql_real_escape_string($memberID);
							$checklogin = mysql_query("SELECT * FROM TrackUploads WHERE id = '".$memberIDinfo."'");
							$row = mysql_fetch_array($checklogin);

							$TrackUrl = $row['TrackUrl'];
							$TrackName = $row['TrackName'];
							$TrackAuthor = $row['TrackAuthor'];

							// Select only the row that matches memberID being requested, eg 123
							$query = "SELECT * FROM TrackUploads WHERE id = '$memberID'";
							$result = mysql_query($query);


							// check that the query returned one row, meaning a match was found
							if(mysql_num_rows($result) == 1)
							{
							?>
								<h1>Track : <?=$TrackName?></h1>
								<center>
								<embed type="application/x-shockwave-flash" src="http://www.google.com/reader/ui/3247397568-audio-player.swf?audioUrl=<?=$TrackUrl?>" width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />

								</center>
								<br />
								<?php
								echo "<b>Artist:</b> $TrackAuthor";
								?>
								<br />
								<?php
								echo "<b>Track Name:</b> $TrackName";
								?>
								<br />

							<?php

							}
							else
							{
								echo '<p style="color:red">Song does not exists</p>';
							}
						}
						else
						{
							echo '<p style="color:red">Invalid link.</p>';
						}

					}

			}
			else
			{
								echo '<p style="color:red">Error: You must be logged in to upload songs.</p>';
			}
			?>

				<br />

		</p>  


	</div>

<!-- content-wrap ends-->	
</div>

<!-- footer starts -->			
<div id="footer-wrap"><div id="footer">				

		<p>
		© 2010 <strong>Musicians Village</strong> | 
		Design by: <a href="http://www.styleshout.com/">styleshout</a> | 
		<?echo 'This page took ', round(array_sum(explode(' ', microtime())) - array_sum(explode(' ', $time_start)), 4), ' seconds to load.<br />';?>

   		      

		</p>		

</div></div>
<!-- footer ends-->	

<!-- wrap ends here -->
</div>

</body>
</html>

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.