Jump to content

aleister1987

Members
  • Posts

    34
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

aleister1987's Achievements

Member

Member (2/5)

0

Reputation

  1. Just to show you where the scripts are coming and going to?
  2. Could i attach a zip file with all the files relating to that file?
  3. My images come from a directory, im sure it's ../catalog/view/theme/default/image/ That's where the slides for the slideshow are placed and used.
  4. Thanks for the reply! Is there anyway i could remove that or simply change the way its written. The actual application itself works. I think they are just warning errors. How would you go about changing that function? I'm not hot on PHP, that's why i have posted lol. An help would be great!
  5. Hello all, I have just downloaded a home banner module for opencart and after trying to get in touch with the original author, it looks like his not supporting his work correctly and im stuck with TWO PHP errors. Warning: Invalid argument supplied for foreach() on line 22. Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag on line 25. The code is as follows:- <?php /* Homepage Slideshow v1.0 Brought to you by Readyman - www.alreadymade.com */ class ControllerModuleHomepageslideshow extends Controller { protected function index() { //$this->language->load('module/homepageslideshow'); //$this->data['heading_title'] = $this->language->get('heading_title'); //$this->load->model('tool/seo_url'); $this->data['config_url'] = $this->config->get('config_url'); $this->data['delay'] = $this->config->get('homepageslideshow_delay'); $this->data['speed'] = $this->config->get('homepageslideshow_speed'); $this->data['pause'] = $this->config->get('homepageslideshow_pause'); $this->data['height'] = $this->config->get('homepageslideshow_height'); $this->data['width'] = $this->config->get('homepageslideshow_width'); $a = unserialize($this->config->get('homepageslideshow_slide_image')); foreach ($a as $key => $row) { $sorting[$key] = $row['sortorder']; } array_multisort($sorting, SORT_ASC, $a); $this->data['slide_images'] = $a; $this->id = 'homepageslideshow'; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/homepageslideshow.tpl')) { $this->template = $this->config->get('config_template') . '/template/module/homepageslideshow.tpl'; } else { $this->template = 'default/template/module/homepageslideshow.tpl'; } $this->render(); } } any help would be greatly appreciated!!
  6. How would i go about adding this feature into the php script?
  7. Would this work. This is on the first page. <?php } function ProcessForm($values) { // INSERT VARIABLES TO DATABASE include("insert_add.php"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $formValues = $_POST; $formErrors = array(); if (!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else ProcessForm($formValues); } else DisplayForm(null, null); ?> and then the database details <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); // Get values from form $model=$_POST['model']; $product=$_POST['product']; $description=$_POST['description']; $price=$_POST['price']; $photo=($_FILES['photo']['name']); // Insert data into mysql $sql="INSERT INTO $tbl_name(model, product, description, price, photo)VALUES('$model', '$product', '$description', '$price', '$photo')"; $result=mysql_query($sql); if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //redirect user to success page header('Location: insertproductsuccess.php); } else { //Gives and error if its not echo "Sorry, There was a problem Uploading your Details, please go back and try again!"; } // close connection mysql_close(); ?> Thanks
  8. @Pikachu2000 Thankyou again... would i need to put the insert commands in the process form function? Im no totally sure where abouts to put them.
  9. I have created a PHP form which includes validation, however.. everytime the validation passes, php redirects the form to another page where mysql code is to insert the variables... for some reason the variables are not being sent at all. Any suggestions. page 1 <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> <?php function VerifyForm(&$values, &$errors) { // Do all necessary form verification // Validate Model Number if (strlen($values['model']) < 4) { $errors['model'] = 'Model Number too short'; } elseif( strlen($values['model']) > 20) { $errors['model'] = 'Model Number too long';} // Validate Price if (is_numeric($values['price']) == 0){ $errors['price'] = 'No Price has been entered';} // Validate Product if(($values['product']) == 0){ $errors['product'] = 'No Product has been selected';} // Validate Image $imageinfo = getimagesize($_FILES['photo']['tmp_name']); if($imageinfo['mime'] != 'image/gif' && $imageinfo['mime'] != 'image/jpeg' && isset($imageinfo)){ $errors['photo'] = 'Image format must be either JPEG or GIF';} // Validate Description if (strlen($values['description']) == 0){ $errors['description'] = 'Description is too short';} return (count($errors) == 0); } function DisplayForm($values, $errors) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Test Area</title> <link rel="stylesheet" href="test.css" type="text/css" media="screen" /> </head> <body> <div id="container"> <h1>Add a Product</h1> <form method="post" id="customForm" action="" enctype="multipart/form-data"> <table> <tr> <td>Model Number:</td> <td><input id="model" type="text" size="30" name="model" value="<?php echo htmlentities($values['model']); ?>"/></td> <td class="error"><p style="color:#FF0000"><?php echo isset($errors['model']) ? $errors['model'] : ''; ?></p></td> </tr> <tr> <td>Choose a Product:</td> <td> <select class="product" name="product"> <option value="0">Please select an option below</option> <option value="19lcdtv">19" LCD TV</option> <option value="22lcdtv">22" LCD TV</option> <option value="26lcdtv">26" LCD TV</option> <option value="32lcdtv">32" LCD TV</option> <option value="37lcdtv">37" LCD TV</option> <option value="37plasmatv">37" Plasma TV</option> <option value="3D">3D Technology</option> <option value="42lcdtv">42" LCD TV</option> <option value="42plasmatv">42" Plasma TV</option> <option value="46plasmatv">46" Plasma TV</option> <option value="50plasmatv">50" Plasma TV</option> <option value="54plasmatv">54" Plasma TV</option> <option value="58plasmatv">58" Plasma TV</option> <option value="65plasmatv">65" Plasma TV</option> <option value="bluraydiscs">Bluray Discs</option> <option value="blurayhomecinema">Bluray Home Cinema System</option> <option value="blurayplayer">Bluray Player</option> <option value="blurayportable">Bluray Portable</option> <option value="blurayrecorder">Bluray Recorder</option> <option value="breadmaker">Breadmakers</option> <option value="cdradio">CD, Radio and Cassette Players</option> <option value="convectorheater">Convector Heaters</option> <option value="cylindercleaner">Cylinder Cleaner</option> <option value="answerphone">DECT Answer Phone</option> <option value="phone">DECT Phone</option> <option value="fire">Dimplex Fires</option> <option value="dishwasher">Dishwashers</option> <option value="dvddiscs">DVD Discs</option> <option value="dvdplayer">DVD Player</option> <option value="dvdportable">DVD Portable</option> <option value="dvdrecorder">DVD Recorder</option> <option value="epilator">Epilators</option> <option value="fanheater">Fan Heaters</option> <option value="freezers">Freezers</option> <option value="fridgefreezer">Fridge-Freezers</option> <option value="hdcamcorder">HD Camcorders</option> <option value="hddcamcorder">HDD Camcorders</option> <option value="homecinema">Home Cinema System</option> <option value="iron">Irons</option> <option value="kettle">Kettles</option> <option value="beauty">Ladies Shavers/Beauty</option> <option value="leads">Leads</option> <option value="shaver">Mens Shavers/Grooming</option> <option value="microsystem">Microsystems</option> <option value="microwavegrill">Microwave (Grill)</option> <option value="microwavesolo">Microwave (Solo)</option> <option value="microwavecombi">Microwave Combination</option> <option value="dvtapes">Mini DV Tapes</option> <option value="minisystems">Minisystems</option> <option value="pvr">Personal Video Recorder (PVR)</option> <option value="projector">Projector</option> <option value="pure">Pure Radios</option> <option value="fridges">Refridgerators</option> <option value="sdcamcorder">SD Camcorders</option> <option value="sdcards">SD/SDHC/SDXC Cards</option> <option value="straighteners">Straighteners</option> <option value="stylishcamera">Stylish Cameras</option> <option value="superzoomcamera">Super Zoom Cameras</option> <option value="toaster">Toasters</option> <option value="tumbledryer">Tumble Dryers</option> <option value="uprightcleaner">Upright Cleaner</option> <option value="brackets">Wall Bracket</option> <option value="washingmachine">Washing Machine</option> </select> </td> <td class="error"><p style="color:#FF0000"><?php echo isset($errors['product']) ? $errors['product'] : ''; ?></p></td> </tr> <tr> <td>Price:</td> <td><input id="price" type="text" size="30" name="price" value="<?php echo isset($values['price']) ? $values['price'] : htmlentities($values['price']) ; '';?>"/></td> <td class="error"><p style="color:#FF0000"><?php echo isset($errors['price']) ? $errors['price'] : ''; ?></p></td> </tr> <tr> <td>Please upload an Image:</td> <td><input id="photo" type="file" size="30" name="photo" value="<?php echo isset($values['photo']) ? htmlentities($values['photo']) : ''; ?>"/></td> <td class="error"><p style="color:#FF0000"><?php echo isset($errors['photo']) ? $errors['photo'] : ''; ?></p></td> </tr> <tr> <td valign="top">Description:</td> <td> <textarea id="description" name="description" cols="" rows=""><?php echo isset($values['description']) ? htmlentities($values['description']) : ''; ?></textarea> </td> <td class="error"><p style="color:#FF0000"><?php echo isset($errors['description']) ? $errors['description'] : ''; ?></p></td> </tr> <tr> <td><input id="submit" name="submit" type="submit" value="Submit" /></td> </tr> </table> </form> </div> </body> </html> <?php } function ProcessForm($values) { //INSERT VARIABLES FROM INSERT_ADD.PHP // Replace with actual page or redirect header ("Location: http://www.example.com"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $formValues = $_POST; $formErrors = array(); if (!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else ProcessForm($formValues); } else DisplayForm(null, null); ?> This is the page which includes database details and insert commands <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //This is the directory where images will be saved $target = "images/"; $target = $target . basename( $_FILES['photo']['name']); // Get values from form $model=$_POST['model']; $product=$_POST['product']; $description=$_POST['description']; $price=$_POST['price']; $photo=($_FILES['photo']['name']); // Insert data into mysql $sql="INSERT INTO $tbl_name(model, product, description, price, photo)VALUES('$model', '$product', '$description', '$price', '$photo')"; $result=mysql_query($sql); if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "<center>The file " . basename($_FILES['photo']['name']) . " has been uploaded, and your information has been added to the directory</center>"; } else { //Gives and error if its not echo "Sorry, There was a problem Uploading your Details."; } // close connection mysql_close(); ?>
  10. @Pikachu2000 Thankyou for all your help and i understand fully you may have a busy schedule. Im still faced with a few errors. I have managed to get the validation errors on screen, there were two missing & symbols. Everything works validation wise, but when i choose a value from the dropdown menu, the variable doesn't save and returns back to default, also when i upload an image to test validation, it always throws back the error. Any ideas or recommendations? I will post the code again with changes.... <?php error_reporting(E_ALL); ini_set('display_errors', 1); ?> <?php function VerifyForm(&$values, &$errors) { // Do all necessary form verification // Validate Model Number if (strlen($values['model']) < 4) { $errors['model'] = 'Model Number too short'; } elseif( strlen($values['model']) > 20) { $errors['model'] = 'Model Number too long';} // Validate Price if (is_numeric($values['price']) == 0){ $errors['price'] = 'No Price has been entered';} // Validate Product if(($values['product']) == 0){ $errors['product'] = 'No Product has been selected';} // Validate Image if ((($_FILES["photo"]["type"] != "image/gif") || ($_FILES["photo"]["type"] != "image/jpeg") || ($_FILES["photo"]["type"] != "image/pjpeg") && ($_FILES["photo"]["size"] > 2000000))) { $errors['photo'] = 'Image format must be either JPG/JPEG/GIF or PNG';} // Validate Description if (strlen($values['description']) == 0){ $errors['description'] = 'Description is too short';} return (count($errors) == 0); } function DisplayForm($values, $errors) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>swiftelectrical.net - Test Area</title> <link rel="stylesheet" href="test.css" type="text/css" media="screen" /> <style> TD.error { color: red; font-weight: bold; } </style> </head> <body> <div id="container"> <h1>Add a Product</h1> <?php if (count($errors) > 0); echo "<p>There were some errors in your submitted form, please correct them and try again.</p>"; ?> <form method="post" id="customForm" action="" enctype="multipart/form-data"> <table> <tr> <td>Model Number:</td> <td><input id="model" type="text" size="30" name="model" value="<?php echo htmlentities($values['model']); ?>"/></td> <td class="error"><?php echo isset($errors['model']) ? $errors['model'] : ''; ?></td> </tr> <tr> <td>Choose a Product:</td> <td> <select class="product" name="product"> <option value="0">Please select an option below</option> <option value="1">19" LCD TV</option> <option value="2">22" LCD TV</option> <option value="3">26" LCD TV</option> <option value="4">32" LCD TV</option> <option value="5">37" LCD TV</option> <option value="6">42" LCD TV</option> <option value="7">37" Plasma TV</option> <option value="8">42" Plasma TV</option> <option value="9">46" Plasma TV</option> <option value="10">50" Plasma TV</option> <option value="11">54" Plasma TV</option> <option value="12">58" Plasma TV</option> <option value="13">Wall Bracket</option> <option value="14">Home Cinema System</option> <option value="15">Bluray Home Cinema System</option> <option value="16">DVD Recorder</option> <option value="17">DVD Player</option> <option value="18">DVD Portable</option> <option value="">Bluray Recorder</option> <option value="">Bluray Player</option> <option value="">Bluray Portable</option> <option value="">Projector</option> <option value="">37" LCD TV</option> <option value="">42" LCD TV</option> <option value="">Personal Video Recorder (PVR)</option> <option value="">3D Technology</option> <option value="">Upright Cleaner</option> <option value="">Cylinder Cleaner</option> <option value="">DECT Phone</option> <option value="">DECT Answer Phone</option> <option value="">Washing Machines</option> <option value="">Tumble Dryers</option> <option value="">Dishwashers</option> <option value="">Fridge-Freezers</option> <option value="">Freezers</option> <option value="">Refridgerators</option> <option value="">Microwave (Solo)</option> <option value="">Microwave (Grill)</option> <option value="">Microwave Combination</option> <option value="">Kettles</option> <option value="">Toasters</option> <option value="">Irons</option> <option value="">Breadmakers</option> <option value="">Microsystems</option> <option value="">Minisystems</option> <option value="">CD, Radio and Cassette Players</option> <option value="">Pure Radios</option> <option value="">Dimplex Fires</option> <option value="">Convector Heaters</option> <option value="">Fan Heaters</option> <option value="">Mens Shavers/Grooming</option> <option value="">Ladies Shavers/Beauty</option> <option value="">Straighteners</option> <option value="">Epilators</option> <option value="">Stylish Cameras</option> <option value="">Super Zoom Cameras</option> <option value="">SD Camcorders</option> <option value="">HD Camcorders</option> <option value="">HDD Camcorders</option> <option value="">Bluray Discs</option> <option value="">DVD Discs</option> <option value="">Leads</option> <option value="">Mini DV Tapes</option> <option value="">SD/SDHC/SDXC Cards</option> </select> </td> <td class="error"><?php echo isset($errors['product']) ? $errors['product'] : ''; ?></td> </tr> <tr> <td>Price:</td> <td><input id="price" type="text" size="30" name="price" value="<?php echo isset($values['price']) ? $values['price'] : htmlentities($values['price']) ; '';?>"/></td> <td class="error"><?php echo isset($errors['price']) ? $errors['price'] : ''; ?></td> </tr> <tr> <td>Please upload an Image:</td> <td><input id="photo" type="file" size="30" name="photo" value="<?php echo isset($values['photo']) ? htmlentities($values['photo']) : ''; ?>"/></td> <td class="error"><?php echo isset($errors['photo']) ? $errors['photo'] : ''; ?></td> </tr> <tr> <td valign="top">Description:</td> <td> <textarea id="description" name="description" cols="30" rows="6"><?php echo isset($values['description']) ? htmlentities($values['description']) : ''; ?></textarea> </td> <td class="error"><?php echo isset($errors['description']) ? $errors['description'] : ''; ?></td> </tr> <tr> <td><input id="submmit" name="submit" type="submit" value="Send" /></td> </tr> </table> </form> </div> </body> </html> <?php } function ProcessForm($values) { //INSERT VARIABLES FROM INSERT_ADD.PHP // Replace with actual page or redirect header ("Location: http://www.example.com"); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { $formValues = $_POST; $formErrors = array(); if (!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else ProcessForm($formValues); } else DisplayForm(null, null); ?>
  11. Okay, Thankyou, would you be able to check in the next couple of days? Thanks for your help!
  12. If you could that would be amazing.
  13. Im sorry to be a pain, do you know exactly where i would put them in my script?
  14. Oyeah sorry, i just ran it and the page displays, Thankyou. However, now i keep getting aload of errors e.g. Notice: Undefined index: model. Is this because it cannot see the variables?
  15. @Pikachu2000 What semicolons are in the wrong place and equal signs where?
×
×
  • 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.