Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Ricky55

  1. Thanks man. He's now saying this can be done in the Apache config using two ports. Getting a bit out of my depth to be honest.
  2. Hi guys, I have hired a developer to help me create an e-commerce project using Laravel. The customer admin and checkout were written by an in house dev that has since left who wrote these outside of Laravel, using Laravel for just the main admin to control orders etc. I told the new dev to throw away anything that didn’t make good sense or fit with modern best practices. He kept the two sections outside of Laravel, although he is using Laravel for authorisation. Looking at his code I have lost all confidence, I’m no expert but he has functions all over the place, repeated in different files there’s no OOP it looks a mess then yesterday he announced that I’d need two instances of php running on my server to get the site to even work. Not two different versions, the same version. I’ve never even heard of this. He said one for Laravel and one for the other parts of the site. Long story I know but what do you guys think? Is this possible? Is it a bad idea? What do you think of what I’ve said? I’ve googled around and it seems possible to run two different versions of php but that’s not what he’s talking about. Any advice very welcome and sorry if I’ve posted in wrong category. Thanks Richard
  3. Hi guys PHP beginner. I have just moved my site to a new server, the old server had an older version of PHP, 5. something and the new server has version 7. I have a script that powers this page https://www.jaybe.com/guarantee-register/ It just sends an email back to the user and also posts the form contents to a mysql database. A developer that I used to work with set this up for me a long time back. Now when I run the script I get this error Fatal error: Uncaught Error: Call to undefined function ereg() in /var/www/jaybe.com/public_html/_/scripts/guarantee.php:37 Stack trace: #0 {main} thrown in /var/www/jaybe.com/public_html/_/scripts/guarantee.php on line 37 The code from the script is here:- <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); $after = "/guarantee-register/thanks.php"; $oops = "/guarantee-register/error.php"; if (isset($_POST['submit']) || isset($_POST['submit_x']) || $_SERVER['REQUEST_METHOD'] == "POST") { $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i"; $profanity = "/(test)/i"; $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i"; $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i"; if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) { exit("<p>Known spam bots are not allowed.</p>"); } foreach ($_POST as $key => $value) { $value = trim($value); if (empty($value)) { if ($key != "email") { exit("<p>Please go back and complete the required fields.</p>"); } } elseif (preg_match($exploits, $value)) { exit("<p>Exploits/malicious scripting attributes aren't allowed.</p>"); } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) { exit("<p>Please keep things clean, no naughty words!</p>"); } $_POST[$key] = stripslashes(strip_tags($value)); } if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) { exit("<p>How can we reply if you don't provide us with a valid email address?</p>"); } conn(); $sql = "INSERT INTO guarantee_reg (`gender`, `forename`, `surname`, `address`, `postcode`, `email`, `product`, `date_purchased`, `retailer`, `opt_in`) VALUES ( '" . mysql_real_escape_string($_POST['gender']) . "', '" . mysql_real_escape_string($_POST['name']) . "', '" . mysql_real_escape_string($_POST['surname']) . "', '" . mysql_real_escape_string($_POST['address']) . "', '" . mysql_real_escape_string($_POST['postcode']) . "', '" . mysql_real_escape_string($_POST['email']) . "', '" . mysql_real_escape_string($_POST['product']) . "', '" . mysql_real_escape_string($_POST['date']) . "', '" . mysql_real_escape_string($_POST['retailer']) . "', '" . mysql_real_escape_string($_POST['opt-in']) . "')"; qry($sql); $recipient = "{$_POST['email']}"; $subject = "Your Jay-Be Guarantee Confirmation"; $message .= "Dear {$_POST['name']}, \n\n Thank you for completing the Jay-Be guarantee registration form. This email is your guarantee registration confirmation, you may wish to print it out for future reference.\n\n"; $year = date('y'); $month = date('m'); $message = ""; $message .= 'Reference number: JB' . $year . $month . "\n\n"; $message .= "The details you provided are as follows: \n\n"; $message .= "Title: {$_POST['title']} \n\n"; $message .= "First Name: {$_POST['name']} \n\n"; $message .= "Surname: {$_POST['surname']} \n\n"; $message .= "Address:\n{$_POST['address']} \n\n"; $message .= "Postcode: {$_POST['postcode']} \n\n"; $message .= "Email: {$_POST['email']} \n\n"; $message .= "Product purchased: {$_POST['product']} \n\n"; $message .= "Date purchased: {$_POST['date']} \n\n"; $message .= "Retailer purchased from: {$_POST['retailer']} \n\n"; $message .= "Added to our marketing database (no if not specified): {$_POST['opt-in']} \n\n"; $headers .= "From: {$_POST['email']}"; if (mail($recipient,$subject,$message,$headers)) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } else { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">"; } } function conn() { $host='localhost'; if($_SERVER['SERVER_ADDR']!='') { $user='user'; $pwd='xxx'; $db='fff'; } else { $user='root!'; $pass=''; $db='fff'; } $conn = mysql_connect($host, $user, $pwd) or die ("<h1>mysql_connect Error</h1>\n <ul>\n <li>Error in: " . $_SERVER['PHP_SELF'] . "</li>\n <li>Selecting database : $db</li>\n <li>With username: $user</li>\n <li>And Password: $pass</li>\n <li>mysql_error: " . mysql_error() . "</li>\n </ul>\n"); mysql_select_db($db, $conn) or die("<h1>mysql_select_db Error</h1>\n <ul>\n <li>Error in: " . $_SERVER['PHP_SELF'] . "</li>\n <li>Selecting database : $db</li>\n <li>With username: $user</li>\n <li>And Password: $pass</li>\n <li>mysql_error: " . mysql_error() . "</li>\n </ul>\n"); return $conn; } function qry($sql) { $res = mysql_query($sql) or die("<h1>Error Querying Database</h1>\n<ul><li>SQL: $sql</li>\n<li>Error: " . mysql_error() . "</li>\n</ul>"); return $res; } function qry_row($sql) { $res = qry($sql); $row = mysql_fetch_assoc($res); return $row; } ?> If anyone can shed any light I'd be very grateful. Thanks Richard
  4. I've just found this code. How would I echo this out into my html? function retailerGet($name=null){ $retailers = array('amazon'=>array('href'=>'http://www.amazon.co.uk/', 'src'=>'amazon.png', 'alt'=>'Amazon'), 'argos'=>array('href'=>'http://www.argos.co.uk/', 'src'=>'argos.png', 'alt'=>'Argos'), 'asda'=>array('href'=>'http://www.asda.co.uk/', 'src'=>'asda.png', 'alt'=>'ASDA')); if($name==null){ $keys = array_keys($retailers); shuffle($keys); return $retailers[$keys[mt_rand(0,count($retailers)-1)]]; }else{ return $names[$name]; } } print_r(retailerGet());
  5. Hi guys I have a series of images that are wrapped with links. I need these to display in a random order with each page refresh. I've had a quick look for some code that I can customise but I'm drawing a blank. I just have <a href="http://www.diy.com"><img src="/_/images/where-to-buy/b-and-q.png" alt="B&Q"></a> Obviously I need to keep the href image source and alt tag together. Is there a way to create an array or switch statement and then output it as needed? Thanks guys
  6. Thank you!!!!! really appreciate that.
  7. Hi guys How would I replace the hyphen in between the date and time with the word at ? I've tried a few things but its not working. Thanks Richard ​echo '<div class="gdlr-result-date">' . date_i18n('l dS - H:ia', $match_date) . '</div>';
  8. Hi guys sorry for being a total noob but when I type this code I'm getting an error. Should this be wrapped in a if ? <?php $selector = (isset($_GET['selector']) ? isset($_GET['selector'] : false; switch($selector) { case 'supreme': $href = '/folding-beds/browse-by/supreme'; $text = 'Supreme Collection'; break; case 'deluxe': $href = '/folding-beds/browse-by/deluxe'; $text = 'Deluxe Collection'; break; case 'airflow': default: $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; break; } ?>
  9. As per usual you guys didn't let me down, best forum on the web is this IMO and I'm not just saying that. You can keep your Stack Overflow with their over restrictive rules. Thanks so much guys I really mean that. I do help people with stuff I know, I'm not just one of these lazy sods. I think I'll use Pyscho's suggestion. Mac_gyver yours looks cool but I don't fully understand it :-) Once again thanks!!!! Ps There are 10 options thats why I asked!
  10. Hi guys I only use PHP every now and again so my knowledge is basic at best. I have this code which is working. I was just wondering if there was a better way of writing this. <?php if(isset($_GET['selector'])) { $selector = $_GET['selector']; } if ($selector == 'airflow') { $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; } if ($selector == 'supreme') { $href = '/folding-beds/browse-by/supreme'; $text = 'Supreme Collection'; } if ($selector == '') { $href = '/folding-beds/browse-by/airflow'; $text = 'Beds with Airflow Fibre Mattresses'; } ?>
  • 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.