Creating valid but dynamic layouts in PHP

Posted: October 19th, 2011 | Author: | Filed under: PHP, Web Development | No Comments »

When creating a dynamic layout in PHP how do you go about creating unique divs if they are being used on a repetitive scale for example galleries portfolios.

I was thinking I could have the following:

but by using this it of course altered my divs with a number therefore screwed up my css.

What would you do?

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

PHP Move_Upload Error

Posted: January 20th, 2011 | Author: | Filed under: PHP | Tags: , , , , | No Comments »

Hello,

I am having another issue with the below code:

$target = "/dir/includes/images/Gallery/";

$target = move_uploaded_file($_FILES ['ImagePath']['tmp_name'], $_SERVER['DOCUMENT_ROOT']. "$target");

When I try and upload I get the following warning;

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/tmp/php1O7Yzh’ to ‘/home/user/public_html/dir/includes/images/Gallery/’ in /home/user/public_html/dir/Admin/includes/class/class.image.php on line 94

I have set the Gallery privileges to 757 and still no luck. What could I try?

Update

Thanks to Sheldon Lendrum, I was told that $target did not have a name, I needed to add . $_FILES['ImagePath']['name'] onto $target

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Javascript Regex Not Working

Posted: January 20th, 2011 | Author: | Filed under: Javascript, Web Development | Tags: , , | No Comments »

Hey Guys,

Could someone please tell me why my regex is not working in the below code for some reason it likes alpha characters as well.

// Check Phone Number
function CheckPhone(sFieldID) {

var bValid = false;
var sVF = id(sFieldID).value; // gets the fields value
var phoneobj = new RegExp("^[0-9]$"); //Checks the Phone is valid

if((sVF.length > 0) && (phoneobj.test(sVF))) {

id(sFieldID +"Error").innerHTML ="Valid";
id(sFieldID +"Error").innerHTML ="Not Valid";
bValid = true;

} else {

id(sFieldID +"Error").innerHTML ="Not Valid";

}

return bValid;

}

Thanks

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

PHP Contact Form

Posted: October 30th, 2010 | Author: | Filed under: PHP, Web Development | Tags: , , , , , , | No Comments »

For all of my websites I use the following PHP process script.  What I would like to know is how other PHP coders would alter or change it to protect it from spammers and xss attacks.  Is PHP Mailer any good? Below is the process code of a form that lets you select the subject.

 
<?php
 
session_start();
 
 
if (!empty($_POST['validation']) && strlen($_POST['validation'])==10){
 
 
 
	$required_fields = array('name', 'email', 'phone', 'subject', 'message');
 
	foreach($_POST as $key => $value) {
 
		$_SESSION[$key] = trim($value);
 
		if(in_array($key, $required_fields) && empty($value)) $errors[] = ucwords($key) .' is required!';
 
	}
 
	if(!$errors) {
 
		$subject = $_SESSION['subject'];
 
		$message = $_SESSION['subject'] ."\n\n";
 
		$message .= "Name: ". $_SESSION['name'] ."\n";
 
		$message .= "E-Mail: ". $_SESSION['email'] ."\n\n";
 
		$message .= "Phone: ". $_SESSION['phone'] ."\n";
 
		$message .= "Message: ". wordwrap ($_SESSION['message']);
 
		$message .= "\n\n";
 
		$message .= date('j/m/Y g:ia');
 
		$headers  = "From:" . $_SESSION['name'] ." <". $_SESSION['email'] .">\n";
 
		$headers .= "Reply-To: ". $_SESSION['name'] ." <". $_SESSION['email'] .">\n";
 
		$headers .= "Return-Path: ". $_SESSION['name'] ." <". $_SESSION['email'] .">\n";
 
		$headers .= "Bcc:\n";
 
 
 
		if(mail($to, $subject, $message,$headers)){
 
			$status = "Thank You, Your enquiry has been sent.";
 
		}else{
 
			$status = "ERROR! There was a system error, Please send your enquiry again.";
 
		}
 
 
	}else{
 
		$status = implode('<br />', $errors	);
 
	}
 
 
 
}
	$_SESSION['error'] = $status;
	header("Location: ../contact.php");
	die();
 
?>
Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Jquery.Cycle Help

Posted: August 20th, 2010 | Author: | Filed under: Jquery | Tags: , , | 1 Comment »

I have got the following code:

What I would like to do is enable it so when the space bar is pressed – the slideshow stops.  When is is pressed again the slideshow resumes.  I have googled and have not come across anything like what I am looking for.

$(document).ready(function() {
$(‘.slideshow’).cycle({
fx: ‘fade’ // choose your transition type, ex: fade, scrollUp, shuffle, etc…
});
});

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Are We Now Getting Quicker Response’s From Businesses

Posted: August 9th, 2010 | Author: | Filed under: Social Media | Tags: , , , , , | No Comments »

Today I was away from my course due to expecting some course text books and with all of this rain at the moment I did not want them getting wet.  So knowing that they were sent on Thursday afternoon  I e-mail the company this morning asking for the track and trace number so I could find out when my package will be arriving.  At about 4PM I placed a tweet over Twitter because I was a bit let down by the service a few minutes later I get a reply.

This has got me thinking due to I have had also quicker responses from other big names businesses via Twitter and from my point of view I find it quicker to get answers from them via Twitter then ring and be placed on hold listening to the Natures Best CD for a hour.

Is social media the new way of getting answers?

Are We Now Getting Quicker Response's Via Social Media Site's?

View Results

Loading ... Loading ...
Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Images and Web

Posted: July 23rd, 2010 | Author: | Filed under: Graphics, Web Development | Tags: , , , , , , | 2 Comments »

Today, We learnt about slicing a website ready for html coding.  The tutor proceeded to tell us that it was best to save graphics in .JPG but the thing is I cannot remember the last time I used a .JPG file in a website.

As a Developer what file format do you use?

What Image Format Do You Use When Coding A Website?

View Results

Loading ... Loading ...

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

General Website Usability Vs Disability Usability

Posted: July 14th, 2010 | Author: | Filed under: Usability, Web Development | Tags: , , , , | 2 Comments »

During my first two days of learning I have come to a very serious issue when it comes to learning about website usability it seems that disability usability gets interlinked with general website usability.  I have thought to myself that this cannot be correct.  I proceeded to send an e-mail to Nic Steenhout from Accessibility NZ stating:

Should disability usability come under its own section away from general usability?

Nic’s response was very informative and along the same lines that I have been thinking over the past couple of days.

“This is, I think, one of the most important issues of accessibility/usability. A lot of people believe that if they know usability, they know accessibility. And it’s not the case at all. “Disability accessibility” is a topic all of its own, it does not come under “general usability”. Note, we talk about disability accessibility, not disability usability.”

Nic also goes onto say “I think it’s a bloody shame that schools/university teaching web development barely touch on usability and rarely discuss accessibility. Particularly in view of legal requirements for websites needing to be accessible.”

Now after all of this I now have another question:

Why is there no teaching about disability usability when it comes to learning/studying about web development and should this be included within the usability guidelines?

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Website Usability

Posted: July 13th, 2010 | Author: | Filed under: Usability, Web Development | Tags: , , , , , , , | 1 Comment »

Today was my first day beginning a Diploma of Web Development at Natcoll and the first section that we are covering is about website usability and the methods that are out there.  The question that I have been pondering over today  is that even through we think that “usability” is common knowledge.

Do you as a Web Developer use any of these Methods in your day to day working environment?.

Please feel free to leave a comment or to vote in the poll.

Do you use any Usability Methods?

View Results

Loading ... Loading ...
Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook

Adding Modules In Oscommerce

Posted: August 12th, 2009 | Author: | Filed under: Web Development | Tags: , , , , | No Comments »

I have been working on a website that has required me to create new shipping methods. The steps below will enable you to create ether new payment or shipping modules.

Yourmodule = Module Name

Step One:
Make a back up copy of the following files:

Your OSC Dir /includes/modules/shipping or payment dictionary/item.php.

and

Your OSC Dir /public_html/includes/languages/english/modules/shipping or payment dictionary/item.php.

Step Two

Open up the modules item.php file and re save it as yourmodule.php.

Step Three

Make the following changes:

/*
$Id: yourmodule.php 1739 2007-12-20 00:52:16Z hpdl $
 
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
 
Copyright (c) 2003 osCommerce
 
Released under the GNU General Public License
*/
 
class yourmodule {
var $code, $title, $description, $icon, $enabled;
 
// class constructor
function yourmodule() {
global $order;
 
$this-&gt;code = 'yourmodule';
$this-&gt;title = MODULE_SHIPPING_YOURMODULE_TEXT_TITLE;
$this-&gt;description = MODULE_SHIPPING_YOURMODULE_TEXT_DESCRIPTION;
$this-&gt;sort_order = MODULE_SHIPPING_YOURMODULE_SORT_ORDER;
$this-&gt;icon = '';
$this-&gt;tax_class = MODULE_SHIPPING_YOURMODULE_TAX_CLASS;
$this-&gt;enabled = ((MODULE_SHIPPING_YOURMODULE_STATUS == 'True') ? true : false);
 
if ( ($this-&gt;enabled == true) &amp;&amp; ((int)MODULE_SHIPPING_YOURMODULE_ZONE &gt; 0) ) {
$check_flag = false;
$check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_YOURMODULE_ZONE . "' and zone_country_id = '" . $order-&gt;delivery['country']['id'] . "' order by zone_id");
while ($check = tep_db_fetch_array($check_query)) {
if ($check['zone_id'] &lt; 1) {             $check_flag = true;             break;           } elseif ($check['zone_id'] == $order-&gt;delivery['zone_id']) {
$check_flag = true;
break;
}
}
 
if ($check_flag == false) {
$this-&gt;enabled = false;
}
}
}
 
// class methods
function quote($method = '') {
global $order, $total_count;
 
$this-&gt;quotes = array('id' =&gt; $this-&gt;code,
'module' =&gt; MODULE_SHIPPING_YOURMODULE_TEXT_TITLE,
'methods' =&gt; array(array('id' =&gt; $this-&gt;code,
'title' =&gt; MODULE_SHIPPING_YOURMODULE_TEXT_WAY,
'cost' =&gt; (MODULE_SHIPPING_YOURMODULE_COST * $total_count) + MODULE_SHIPPING_YOURMODULE_HANDLING)));
 
if ($this-&gt;tax_class &gt; 0) {
$this-&gt;quotes['tax'] = tep_get_tax_rate($this-&gt;tax_class, $order-&gt;delivery['country']['id'], $order-&gt;delivery['zone_id']);
}
 
if (tep_not_null($this-&gt;icon)) $this-&gt;quotes['icon'] = tep_image($this-&gt;icon, $this-&gt;title);
 
return $this-&gt;quotes;
}
 
function check() {
if (!isset($this-&gt;_check)) {
$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_YOURMODULE_STATUS'");
$this-&gt;_check = tep_db_num_rows($check_query);
}
return $this-&gt;_check;
}
 
function install() {
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable fifteen Shipping', 'MODULE_SHIPPING_YOURMODULE_STATUS', 'True', 'Do you want to offer per fifteen rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Shipping Cost', 'MODULE_SHIPPING_YOURMODULE_COST', '2.50', 'The shipping cost will be multiplied by the number of items in an order that uses this shipping method.', '6', '0', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Handling Fee', 'MODULE_SHIPPING_YOURMODULE_HANDLING', '0', 'Handling fee for this shipping method.', '6', '0', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_YOURMODULE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_YOURMODULE_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_YOURMODULE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
}
 
function remove() {
tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this-&gt;keys()) . "')");
}
 
function keys() {
return array('MODULE_SHIPPING_YOURMODULE_STATUS', 'MODULE_SHIPPING_YOURMODULE_COST', 'MODULE_SHIPPING_YOURMODULE_HANDLING', 'MODULE_SHIPPING_YOURMODULE_TAX_CLASS', 'MODULE_SHIPPING_YOURMODULE_ZONE', 'MODULE_SHIPPING_YOURMODULE_SORT_ORDER');
}
}

Step Four

Open up the languages item.php file and re save it as yourmodule.php.

Step Five

Make the following changes:

<?php
/*
$Id: yourmodule.php 1739 2007-12-20 00:52:16Z hpdl $
 
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
 
Copyright (c) 2002 osCommerce
 
Released under the GNU General Public License
*/
 
define('MODULE_SHIPPING_YOURMODULE_TEXT_TITLE', 'Module Text');
define('MODULE_SHIPPING_YOURMODULE_TEXT_DESCRIPTION', 'ModuleText');
define('MODULE_SHIPPING_YOURMODULE_TEXT_WAY', 'Module Text');
?>

Step Five

Install the modules via OSC Admin

Share and Enjoy:
  • Twitter
  • Google Bookmarks
  • del.icio.us
  • RSS
  • Facebook