Jump to content

Jamesking56

Members
  • Content Count

    150
  • Joined

  • Last visited

Posts posted by Jamesking56

  1. Hi, I have a Web Based CV created that uses HTML & CSS. I wish to add a 'Download as PDF' button to it which would link to a PHP page to generate a PDF version of my CV and download straight to their computer. What is the best way to do this in PHP?

  2. Hi, I want a URL Rewrite .htaccess file but don't know how to make it for what I need. Firstly, I want it to force www. for my domain. Secondly, I want it to hide the .php extension and add a slash to the end of the url:

    http://www.example.com/page.php -> http://www.example.com/page/

    Thirdly, for my about section I wish to have subdirectories that go to a php file:

    http://www.example.com/about/company/ -> http://www.example.com/about-company.php

    Can someone make this into a .htaccess for me?

    • Like 6
  3. Hi,I want a staff area that will allow my staff to: - Send Files - Send Messages - See FAQs / Knowledgebase guides - Collaborate together with my Git Repos - Manage their own information - See the staff announcements - Access Links for staff to use - See Meeting dates and times and say whether they're attending or notStuff like that

  4. Still confused :)

    <?php$page = "audition";$pagename = "Audition";require_once('core.php');if ($_POST['submit']) {	// Process Form then send to Thanks Page	$name = $_POST['name'];	$email = $_POST['email'];	$video = $_POST['video'];	$act_desc = $_POST['act_desc'];		// Check if the user has filled them in!	if (!$name || $name == "") {		// No Name!		$error = "Your name could not be included with the form. (ErrorCode #3)";	}	if (!$email || $email == "" && !$error) {		// No Email!		$error = "Your Email Address could not be included with the form. (ErrorCode #3)";	}	if (!$video || $video == "" && !$error) {		// No Email!		echo $_FILES["file"]["tmp_name"];		$error = "Please attach your video. (ErrorCode #4)";	}	if (!$act_desc || $act_desc == "" && !$error) {		// No Desc!		$error = "Please tell us about your act. (ErrorCode #4)";	}	if (!$error) {		// Form Valid!		// Upload the video and grab link back		if (file_exists("upload/".$_FILES["file"]["name"])) {			$filename = $_FILES["file"]["name"] . "_new";		}		else {			$filename = $_FILES["file"]["name"];		}		$upload_file = move_uploaded_file($_FILES["file"]["tmp_name"],"upload/" . $filename);		$videolink = "upload/".$filename;				// Debug		if (!$upload_file) {			echo "File Upload / Move failed! (ErrorCode: #13)";		}		else {			echo "File is fine :). (".$videolink.")";		}				// Tell the DB		$query2 = mysql_query("UPDATE users SET auditioned = 1 WHERE uid = '".$uid."'");		if (!$query2) {			$error = "Could not contact database. (ErrorCode #8)";		}		else {			// SENT!			// SEND EMAILS!			$msgtov = "$name has sent a video audition via CUT on Facebook:			Facebook Profile: http://www.facebook.com/profile.php?id=$uid			Name: $name			Email Address: $email			Link to Video: LINK			Description of Act: 			$act_desc			Please do not delete this email! The Database does not hold records for this information!";			$mail1 = mail($config['email'],"Form Submission (Facebook)",$msgtov,"From: Mailer Bot");						// Mail2			$msgtou = "Thanks for sending your video audition for CUT!			If you need any assistance please feel free to email us by replying to this email.			We will contact you soon.			Our FB Page: LINK";			$mail2 = mail($email,"Thanks for Auditioning for CUT!",$msgtou,"From: ".$config['email']);			}		}	}?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head>	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">	<title><index><?php echo $pagetitle; ?></title>	<meta name="generator" content="TextMate http://macromates.com/">	<meta name="author" content="James King">	<!-- Date: 2011-02-03 --></head><body><div id="fb-root"></div>	<script type="text/javascript"><?phpif ($top_href) {	?>	top.location.href = "<?php echo $top_href; ?>";	<?php} else {	?>	window.fbAsyncInit = function() {	  FB.init({		appId   : <?php echo $facebook->getAppId(); ?>,		session : <?php echo json_encode($session); ?>, // don't refetch the session when PHP already has it		status  : true, // check login status		cookie  : <?php echo $config['fb']['cookie']; ?>, // enable cookies to allow the server to access the session		xfbml   : true // parse XFBML	  });	  // whenever the user logs in, we refresh the page	  FB.Event.subscribe('auth.login', function() {		window.location.reload();	  });	};	(function() {	  var e = document.createElement('script');	  e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';	  e.async = true;	  document.getElementById('fb-root').appendChild(e);	}());	<?php}?></script><style type="text/css" media="screen">	h1, h2 {		font-family: Verdana;	}	.form {		border: solid 1px gray;		background: silver;		width: 75%;		height: auto;	}</style><center><?phpif ($auditioned == 0) {	?>	<?php		if ($error) {		echo "<font color=\"red\">Error: <b>".$error."</b></font><br /><br />";	}		?>	<h1>Submit your Video for CUT!</h1>	<h6>(All Fields are Required And You must live near CUT to attend)</h6><br />	<div class="form">		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" accept-charset="utf-8" enctype="multipart/form-data">		<br /><input type="hidden" name="uid" value="<?php echo $uid; ?>">		<input type="hidden" name="name" value="<?php echo $me['name']; ?>">		<input type="hidden" name="email" value="<?php echo $me['email']; ?>">		Please Attach your Video: <br /><input type="file" name="video" value=""><br /><br />		Please Explain Your Act:<br /><textarea name="act_desc" rows="12" cols="60"><?php echo $act_desc; ?></textarea><br /><br />		<input type="submit" name="submit" value="Submit Video Audition"><br /><br />	</form></div><br />	<?php}else {	?>	<p>Thanks for Auditioning! Please check your emails for our reply. If you experience any issues please email us at <?php echo $config['email']; ?>.</p>	<?php}?><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like-box href="LINK?v=info" width="292" show_faces="true" stream="false" header="true"></fb:like-box></center></body></html>

  5. Hey guys!I'm making a facebook app for auditions where people can upload a video audition with their name and email to audition.I want it so that there is just one form with name, email and file.How do I do this so I can upload a video to my server and put the name and email in the database with the link to the video?I'm confused :)

  6. Again, I'd recommend SimpleXML over DOMDocument. Simple XML was made for this kind of thing. Here's an example of what it might look like:
    $feed = new SimpleXMLElement('FEED_URL_HERE', 0, true);foreach ($feed->channel as $channel) {	echo('Channel Title:'.$channel->title);	echo('Channel Description:'.$channel->description);	foreach ($channel->item as $item) {		echo('Item Title: '.$item->title);		echo('Item Description: '.$item->description);	}}

    This worked! Thanks guys its all working now and I've even limited it to 5 records and everything! Thank you! :)
  7. I'm still stuck with this...Can someone show me the code for it?My code is currently:

    	// Get Blog	$xmlDoc = new DOMDocument();	$xmlDoc->load("FEED URL HERE");		$x = $xmlDoc->documentElement;	foreach( $x->childNodes as $item )	{		//$powercp_blog .= $item->nodeName . " = " . $item->nodeValue . "<br />";		echo $item->nodeName . " | ";		if ( $item->nodeName == "channel" )		{			echo $item->nodeName;			$powercp_blog .= "<p>";			$powercp_blog .= $item->nodeValue;			$powercp_blog .= "</p>";		}	}		$template->assign('powercp_blog', $powercp_blog);

    This displays it all stupidly (obviously).

  8. I'm still getting the same issue, My Server does have MySQL and it can connect but when my extended class detects if its connected or not it thinks it isn't and tries again to connect...Its something to do with how my variables are stored...I need my variables shared between all extended classes!How can I do this?

  9. After changing to public and updating my settings class back to using $this I get the error:"Oops! That database type is unsupported in this version of PowerCP."How come I still get the same error?

  10. Hi,Basically I have made a small database class for handling DB connectionsIt connects by itself once declared and sets $currconn as true if it is connected.My other classes Extend from my database class and check if its connected by checking the Parent $currconn.If its not connected it instructs my database class to connect.Now here is my problem.My DB class is declared and connectsMy Settings class (Extending Database) then checks for connection but sees it as FALSE! and tries to get the database to connect with no details?WTF? is going on?Database.class.php:

    <?php	####################################################	## PowerCP ~ The Ultimate Radio System	## PowerCP requires a license for use. It is illegal	## to bypass the licensing and encryption systems.	####################################################	## (c) Copyright PowerCP, All Rights Reserved	## www.powercp.co.uk for more information & support	####################################################	## File Name: database.class.php	## Description: The Database Class manages connections	## to many different database systems.	## Category: Class	####################################################	class Database	{		public static $dbtype;		public static $dbconn;		public static $dbuser;		public static $dbpass;		public static $dbname;		public static $currconn;				public function _construct ( $dbtype=null, $dbconn=null, $dbuser=null, $dbpass=null, $dbname=null )		{			if ( !$this->currconn )			{				// No Current Connection!				// Set Vars				$this->dbtype = $dbtype;				$this->dbconn = $dbconn;				$this->dbuser = $dbuser;				$this->dbpass = $dbpass;				$this->dbname = $dbname;								// Connect				$connectit = $this->connect($this->dbtype, $this->dbconn, $this->dbuser, $this->dbpass, $this->dbname);				if ( !$connectit )				{					die("Error: Could not connect to database!");				}				else				{					// Do Nothing!				}			}		}				function connect ( $type, $conn, $user, $pass, $name )		{			// Check type			switch ( $type )			{				case 'mysql':					// Connect to MySQL & Select DB					$tryandconn = @mysql_select_db($this->dbname, @mysql_connect($this->dbconn, $this->dbuser, $this->dbpass));					if ( !$tryandconn )					{						$this->currconn = false;						die("Error! Could not connect to MySQL Database! Please check your settings!");					}					else					{						$this->currconn = true;						return true;					}				break;				default:					// Whoops! Not supported!					die("Oops! That database type is unsupported in this version of PowerCP.");				break;			}		}				function query ( $sql )		{			// Check for Connection			if ( !$this->currconn )			{				// Not connected!				$this->connect($this->dbtype, $this->dbconn, $this->dbuser, $this->dbpass, $this->dbname);			}						// Do Query			if ( !$sql )			{				return false;			}			else			{				// Type Switch				switch ( $this->dbtype )				{					case 'mysql':						$query = @mysql_query(@mysql_real_escape_string($sql));						return $query;					break;				}			}		}				function fetch_array ( $query )		{			// Check for Connection			if ( !$this->currconn )			{				// Not connected!				$this->connect($this->dbtype, $this->dbconn, $this->dbuser, $this->dbpass, $this->dbname);			}			// Do Query			if ( !$sql )			{				return false;			}			else			{				// Type Switch				switch ( $this->dbtype )				{					case 'mysql':						$array = @mysql_fetch_array($query);						return $array;					break;				}			}		}				function fetch_assoc ( $query )		{			// Check for Connection			if ( !$this->currconn )			{				// Not connected!				$this->connect($this->dbtype, $this->dbconn, $this->dbuser, $this->dbpass, $this->dbname);			}			// Do Query			if ( !$sql )			{				return false;			}			else			{				// Type Switch				switch ( $this->dbtype )				{					case 'mysql':						$array = @mysql_fetch_assoc($query);						return $assoc;					break;				}			}		}	}?>

    Settings.class.php:

    <?php	####################################################	## PowerCP ~ The Ultimate Radio System	## PowerCP requires a license for use. It is illegal	## to bypass the licensing and encryption systems.	####################################################	## (c) Copyright PowerCP, All Rights Reserved	## www.powercp.co.uk for more information & support	####################################################	## File Name: settings.class.php	## Description: The Settings Class uses the Database	## to grab settings.	## Category: Class	####################################################		class Settings extends Database	{		function getsetting ( $setting )		{			if ( !parent::$currconn )			{				parent::connect(parent::$dbtype, parent::$dbconn, parent::$dbuser, parent::$dbpass, parent::$dbname);			}			// Grab the setting			return parent::query("SELECT `value` FROM settings WHERE `key`='".filter($setting)."'");		}				function setsetting ( $key, $newsetting )		{			if ( !parent::$currconn )			{				parent::connect(parent::$dbtype, parent::$dbconn, parent::$dbuser, parent::$dbpass, parent::$dbname);			}			// Set the setting			$insert = parent::query("UPDATE settings SET `value`='".filter($newsetting)."' WHERE `key`='".filter($key)."'");		}	}?>

    So my page now says "HERE!Oops! That database type is unsupported in this version of PowerCP.". I used the 'HERE!' to debug it so I could track where its at.Can someone tell me how I can resolve this so it only connects once and all other classes know that it has connected?

  11. Look into the source of either of the packages I linked you to... you do it like that, but with less code (which is why I must ask you - why not use either of those?).
    OK, I didn't want to use stuff like that because 1. I wanted to use my own code and 2. it seemed to overcomplicate things by adding loads of confusing options like disabling queries and debug modes that I really don't want or need.
  12. Hi,I need a class that can connect to different database types and query them if needed.In a config it will set:Database Type (MySQL, SQLite etc.)Database Connection (localhost / IP / Hostname)Database Username (root)Database Password (password)Database Name (nameofdb)How can I do this in a PHP class so all i'd have to do was:

    $db = new Database($type, $conn, $user, $pass, $name);$db->query("SELECT * FROM whatever");

    in my script?What is the best way to achieve this?

×
×
  • Create New...