Jump to content

ianhaney

Members
  • Content Count

    275
  • Joined

  • Last visited

Community Reputation

0 Neutral

About ianhaney

  • Rank
    Advanced Member

Profile Information

  • Gender
    Not Telling
  1. I have a blog on my website and the blogs content is stored in a database. On my home page I have the two recent articles displayed on my home page but I have to change them manually so I add the recent article on the home page in the first column and the second most recent one in the next column so they are side by side. What I want to do is automatically display the blogs image and blog title from the database and display on the home page so I don't have to keep changing it manually My current code looks like the following <div class="block"> <div class="container"> <h3 class="text-center"><span class="color">Recent Blog Articles</span></h3> <div class="row"> <div class="col-md-6"> <div class="text-img animation" data-animation="fadeInLeft" data-animation-delay="0.5s"> <a href="https://www.it-doneright.co.uk/blog/one-year-to-go-until-end-of-support-for-windows-7"> <div class="image"> <img class="img-responsive" src="https://www.it-doneright.co.uk/images/blog/windows7-eos-new.jpg" alt="One year to go until end of support for Windows 7"> </div> <p>One year to go until end of support for Windows 7</p> </a> </div> </div> <div class="col-md-6"> <div class="text-img animation" data-animation="fadeInLeft" data-animation-delay="0.5s"> <a href="https://www.it-doneright.co.uk/blog/windows-10-is-going-to-require-7gb-of-storage-for-future-updates"> <div class="image"> <img class="img-responsive" src="https://www.it-doneright.co.uk/images/windows-ten-updates-needing-7gb-space-on-hard-drive.jpg" alt="Windows 10 is going to require 7gb of storage for future updates"> </div> <p>Windows 10 is going to require 7gb of storage for future updates</p> </a> </div> </div> </div> </div> </div> I did look on Google before posting but could not get my head around how to do it, could anyone point me in the right direction or start me off and will have a go
  2. I need some help with a mobile nav menu, it works to a point, the issue when the nav menu is expanded and I scroll down the site to view the categories in the menu as there are quite a lot, the nav menu collapses. I am unsure how to fix it, the coding I have is below <script> /* MOBILE COLLAPSE MENU */ (function($) { $.fn.collapsable = function(options) { // iterate and reformat each matched element return this.each(function() { // cache this: var obj = $(this); var tree = obj.next('.navigation'); obj.click(function(){ if( obj.is(':visible') ){tree.toggle();} }); $(window).resize(function(){ if ( $(window).width() <= 570 ){tree.attr('style','');}; }); }); }; })(jQuery); </script> <script> jQuery(document).ready(function($) { $('.slide-trigger').collapsable(); }); </script> <?php if ($categories) { ?> <nav class="group"> <h2 class="navheader slide-trigger">Menu <span></span></h2> <ul class="navigation group"> <?php foreach ($categories as $category) { ?> <li><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a> <?php if ($category['children']) { ?> <div> <?php for ($i = 0; $i < count($category['children']);) { ?> <ul> <?php $j = $i + ceil(count($category['children']) / $category['column']); ?> <?php for (; $i < $j; $i++) { ?> <?php if (isset($category['children'][$i])) { ?> <li><a href="<?php echo $category['children'][$i]['href']; ?>"><?php echo $category['children'][$i]['name']; ?></a></li> <?php } ?> <?php } ?> </ul> <?php } ?> </div> <?php } ?> </li> <?php } ?> </ul> </div> </ul> </nav> <?php } ?> nav.group { margin: -19px 0px 0px -15px; width: 330px; clear: both; } .navigation { max-width: none; background: #000; padding: 0; } .navigation li { float: left; } .navigation li a { display: block; color: #fff; padding: 10px; } .navigation li a:hover { background: #0fcaf2; } .navheader { font-size: 12px; } .slide-trigger { display: none; /* need this */ /*border: 1px solid #CCCCCC;*/ border-bottom-left-radius: 10px; border-bottom-right-radius: 10px; -webkit-border-bottom-left-radius: 10px; -webkit-border-bottom-right-radius: 10px; -moz-border-radius-bottomleft: 10px; -moz-border-radius-bottomright: 10px; background: rgba(179,220,237,1); background: -moz-linear-gradient(-45deg, rgba(179,220,237,1) 0%, rgba(41,184,229,1) 50%, rgba(188,224,238,1) 100%); background: -webkit-gradient(left top, right bottom, color-stop(0%, rgba(179,220,237,1)), color-stop(50%, rgba(41,184,229,1)), color-stop(100%, rgba(188,224,238,1))); background: -webkit-linear-gradient(-45deg, rgba(179,220,237,1) 0%, rgba(41,184,229,1) 50%, rgba(188,224,238,1) 100%); background: -o-linear-gradient(-45deg, rgba(179,220,237,1) 0%, rgba(41,184,229,1) 50%, rgba(188,224,238,1) 100%); background: -ms-linear-gradient(-45deg, rgba(179,220,237,1) 0%, rgba(41,184,229,1) 50%, rgba(188,224,238,1) 100%); background: linear-gradient(135deg, rgba(179,220,237,1) 0%, rgba(41,184,229,1) 50%, rgba(188,224,238,1) 100%); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b3dced', endColorstr='#bce0ee', GradientType=1 ); cursor: pointer; margin-left: 15px; margin-right: 15px; } .slide-trigger span { background-image: url("../image/dropdown-arrows.png"); background-position: 0 -14px; display: block; float: right; margin-top: 3px; height: 14px; width: 32px; } .slide-trigger { display: block; padding: 10px; } .no-js .slide-trigger { display: none; } .navigation { display: none; } .no-js .navigation { display: block; } .navigation { margin: -9px 15px; z-index: 9999; position: absolute; } .navigation li { float: none; list-style-type: none; width: 300px; } .navigation li a { border-bottom: 1px solid #fff; } Thank you in advance, the site is www.ccgretail.co.uk
  3. I have but can't seem to find any open source scripts, I might have a look on codecanyon if are not any open source scripts
  4. I have been asked by current client if a client registration/login and file upload with admin system can be added to his current website, the features the client requires are below 1) A registration script 2) A login script with forgot password feature 3) A admin side where the client can upload files like PDF's or jpg's to the users account and enter a password to view/download the uploaded file by admin 4) The admin side to also manage the users that sign up Are there any open source scripts out there that can do the above in php/mysqli or PDO? Thank you in advance
  5. UPDATE: I have solved it and also managed to do the array of choices, it seems to work when I tested it, I now have the following coding <?php $selection=array('In Queue','Working on','Awaiting Parts','Ready for Collection/Delivery','Complete','Unable To Repair'); echo ' <strong>Repair Status:</strong> <select name="status"> <option value="0">Please Select Option</option>'; foreach($selection as $selection){ $selected=($status == $selection)? "selected" : ""; echo '<option '.$selected.' value="'.$selection.'">'.$selection.'</option>'; } echo '</select>'; ?>
  6. I tried the coding below <select name="status"> <option value="In Queue" <?php if ($row['status'] == 'In Queue') 'selected = "selected"'; ?>>In Queue</option> <option value="Working on" <?php if ($row['status'] == 'Working On') 'selected = "selected"'; ?>>Working on</option> <option value="Awaiting Parts" <?php if ($row['status'] == 'Awaiting Parts') 'selected = "selected"'; ?>>Awaiting Parts</option> <option value="Ready for Collection/Delivery" <?php if ($row['status'] == 'Ready for Collection/Delivery') 'selected = "selected"'; ?>>Ready for Collection/Delivery</option> <option value="Complete" <?php if ($row['status'] == 'Complete') 'selected = "selected"'; ?>>Complete</option> <option value="Unable To Repair" <?php if ($row['status'] == 'Unable To Repair') 'selected = "selected"'; ?>>Unable To Repair</option> </select> buy gives the following error Notice: Undefined Variable: row I am not sure what it should be, I changed it to $status instead of $row but got a illegal string error
  7. Oh right ok, sorry not 100% on PHP, how would it look in regards to storing the choices in a database table and then looping over the choices to build the output?
  8. Is that in the following I think EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ?, job_cost = ?, part_cost = ?, profit = ? WHERE id=?")) { $stmt->bind_param("ssssssssssssssssi", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, send_sms FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $send_sms); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, NULL, $id, $send_sms); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-repairs-tracking.php"); } } }
  9. Hi I need bit of help regarding dropdown values when editing a record using php. I edit a record using a html form and php to process the form and it saves all ok in the database but when I edit the record, it shows the first select dropdown value within the form instead of the value when the form saves to the database Can anyone help please, I have added the coding below <?php ini_set('display_startup_errors',1); ini_set('display_errors',1); error_reporting(-1); ?> <?php /* Allows the user to both create new records and edit existing records */ // connect to the database include("connect-db.php"); // creates the new/edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($customer_name = '', $customer_email = '', $customer_phone = '', $computer_make = '', $computer_model = '', $technician = '', $status = '', $exrdate = '', $exrtime = '', $exstdate = '', $exstime = '', $deltype = '', $comments = '', $job_cost = '', $part_cost = '', $profit = '', $error = '', $id = '', $send_sms = '') { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title> <?php if ($id != '') { echo "Edit Repair Tracking"; } else { echo "New Repair Tracking"; } ?> </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet"href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/blitzer/jquery-ui.css"/> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" /> <script src="js/jquery.ui.timepicker.js"></script> <link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ui.timepicker.css" /> <script> $(function() { $("#exrdate").datepicker({ showButtonPanel: true, dateFormat: "yy/mm/dd", showOn:"both" }); }); $(function() { $("#exstdate").datepicker({ showButtonPanel: true, dateFormat: "yy/mm/dd", showOn:"both" }); }); </script> <script> $(document).ready(function() { $('#exrtime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); $('#exstime').timepicker({ defaultTime: '12:00', showLeadingZero: true, showNowButton: true, showCloseButton: true, showDeselectButton: true, showOn: 'both', }); }); </script> <!--<script src="//cdn.ckeditor.com/4.5.5/full/ckeditor.js"></script>--> <script type="text/javascript"> function doCalc() { var job_cost = parseFloat(document.getElementById('job_cost').value); var part_cost = parseFloat(document.getElementById('part_cost').value); var profit = job_cost - part_cost; profit = profit.toFixed(2); document.getElementById('profit').value = profit; } </script> </head> <body> <div id="logo"> <img src="https://www.it-doneright.co.uk/admin/repairs-tracking/images/logo/it-done-right.jpg" alt="" title=""> </div> <? session_start(); if($_SESSION['user']==''){ header("Location:../index.php"); }else{ include("../config.php"); $sql=$dbh->prepare("SELECT * FROM users WHERE id=?"); $sql->execute(array($_SESSION['user'])); while($r=$sql->fetch()){ echo "<div class='home-content'>"; echo "<center><h2>Hello, ".$r['username']."</h2>"; echo "<a href='../logout.php'>Log Out</a> <br><br> <a href='../index.php'>Home</a></center>"; echo "</div>"; echo "<br>"; } } ?> <?php include("nav-menu.php"); ?> <h1><?php if ($id != '') { echo "Edit Repair"; } else { echo "New Repair"; } ?></h1> <?php if ($error != '') { echo "<div style='padding:4px; border:1px solid red; color:red'>" . $error . "</div>"; } ?> <div style="float: left;"> <u>NOTES</u> <br><br> <strong> ENTER MOBILE WITH 44 IN FRONT AND <br> NO SPACES (E.G. 447538503276) </strong> </div> <form action="" method="post" class="basic-grey"> <div> <?php if ($id != '') { ?> <input type="hidden" name="id" value="<?php echo $id; ?>" /> <p>Repair ID: <?php echo $id; ?></p> <?php } ?> <br> <strong>Customer Name:</strong> <input type="text" name="customer_name" value="<?php echo $customer_name; ?>"/> <br/> <strong>Customer Email:</strong> <input type="text" name="customer_email" value="<?php echo $customer_email; ?>"/> <br> <strong>Customer Phone:</strong> <input type="text" name="customer_phone" value="<?php echo $customer_phone; ?>"/> <?php if($send_sms == 1):?> <br /><strong style='color:red;'>SMS ALREADY SENT</strong><br /><br /> <?php else:?> <br> <strong>Send SMS Confirmation:</strong> <input type="checkbox" name="send_sms" value="yes"/> <br /><br /> <?php endif;?> <strong>Computer Make:</strong> <input type="text" name="computer_make" value="<?php echo $computer_make; ?>"/> <br> <strong>Computer Model:</strong> <input type="text" name="computer_model" value="<?php echo $computer_model; ?>"/> <br> <strong>Assigned to Technician:</strong> <select name="technician"> <option value="Ian Haney">Ian Haney</option> </select> <br> <strong>Repair Status:</strong> <select name="status"> <option value="In Queue">In Queue</option> <option value="Working on">Working on</option> <option value="Awaiting Parts">Awaiting Parts</option> <option value="Ready for Collection/Delivery">Ready for Collection/Delivery</option> <option value="Complete">Complete</option> <option value="Unable To Repair">Unable To Repair</option> </select> <br> <strong>Expected Start Date:</strong> <input type="text" name="exstdate" value="<?php echo $exstdate; ?>" id="exstdate" /> <br><br> <strong>Expected Start Time:</strong> <input type="time" name="exstime" value="<?php echo $exstime; ?>" id="exstime"/> <br><br> <strong>Expected Repair Date:</strong> <input type="text" name="exrdate" value="<?php echo $exrdate; ?>" id="exrdate"/> <br><br> <strong>Expected Repair Time:</strong> <input type="time" name="exrtime" value="<?php echo $exrtime; ?>" id="exrtime"/> <br><br> <strong>Delivery Type:</strong> <select name="deltype"> <option value="Customer Pickup">Customer Pickup</option> <option value="Delivery">Delivery</option> </select> <br> <strong>Comments:</strong> <br> <textarea name="comments"><?php echo $comments; ?></textarea> <br> <strong>Job Repair Cost:</strong> <input type="text" name="job_cost" id="job_cost" value="<?php echo $job_cost; ?>" onBlur="doCalc(this.form)" /> <br> <strong>Parts Cost:</strong> <input type="text" name="part_cost" id="part_cost" value="<?php echo $part_cost; ?>" onblur="doCalc(this.form)" /> <br> <strong>Profit:</strong> <input type="text" name="profit" id="profit" value="<?php echo $profit; ?>" /> <br> <input type="submit" name="submit" value="Add/Update Repair Tracking" /> </div> </form> </body> </html> <?php } /* EDIT RECORD */ // if the 'id' variable is set in the URL, we know that we need to edit a record if (isset($_GET['id'])) { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { // make sure the 'id' in the URL is valid if (is_numeric($_POST['id'])) { // get variables from the URL/form $id = $_POST['id']; $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $customer_phone == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $customer_phone, $computer_make, $computer_model, $comments, $error, $id); } else { // if everything is fine, update the record in the database if ($stmt = $mysqli->prepare("UPDATE repairs SET customer_name = ?, customer_email = ?, customer_phone = ?, computer_make = ?, computer_model = ?, technician = ?, status = ?, exrdate = ?, exrtime = ?, exstdate = ?, exstime = ?, deltype = ?, comments = ?, job_cost = ?, part_cost = ?, profit = ? WHERE id=?")) { $stmt->bind_param("ssssssssssssssssi", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $id); $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } // redirect the user once the form is updated header("Location: view-repairs-tracking.php"); } } // if the 'id' variable is not valid, show an error message else { echo "Error!"; } } // if the form hasn't been submitted yet, get the info from the database and show the form else { // make sure the 'id' value is valid if (is_numeric($_GET['id']) && $_GET['id'] > 0) { // get 'id' from URL $id = $_GET['id']; // get the recod from the database if($stmt = $mysqli->prepare("SELECT id, customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit, send_sms FROM repairs WHERE id=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->bind_result($id, $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, $send_sms); $stmt->fetch(); // show the form renderForm($customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit, NULL, $id, $send_sms); $stmt->close(); } // show an error if the query has an error else { echo "Error: could not prepare SQL statement"; } } // if the 'id' value is not valid, redirect the user back to the view.php page else { header("Location: view-repairs-tracking.php"); } } } /* NEW RECORD */ // if the 'id' variable is not set in the URL, we must be creating a new record else { // if the form's submit button is clicked, we need to process the form if (isset($_POST['submit'])) { $country_code = '44'; // get the form data $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES); $customer_email = htmlentities($_POST['customer_email'], ENT_QUOTES); $customer_phone = htmlentities($_POST['customer_phone'], ENT_QUOTES); $computer_make = htmlentities($_POST['computer_make'], ENT_QUOTES); $computer_model = htmlentities($_POST['computer_model'], ENT_QUOTES); $technician = htmlentities($_POST['technician'], ENT_QUOTES); $status = htmlentities($_POST['status'], ENT_QUOTES); $exrdate = htmlentities($_POST['exrdate'], ENT_QUOTES); $exrtime = htmlentities($_POST['exrtime'], ENT_QUOTES); $exstdate = htmlentities($_POST['exstdate'], ENT_QUOTES); $exstime = htmlentities($_POST['exstime'], ENT_QUOTES); $deltype = htmlentities($_POST['deltype'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $job_cost = htmlentities($_POST['job_cost'], ENT_QUOTES); $part_cost = htmlentities($_POST['part_cost'], ENT_QUOTES); $profit = htmlentities($_POST['profit'], ENT_QUOTES); // check that firstname and lastname are both not empty if ($customer_name == '' || $computer_make == '' || $computer_model == '' || $comments == '') { // if they are empty, show an error message and display the form $error = 'ERROR: Please fill in all required fields!'; renderForm($customer_name, $computer_make, $computer_model, $comments, $error); } else { // insert the new record into the database if ($stmt = $mysqli->prepare("INSERT repairs (customer_name, customer_email, customer_phone, computer_make, computer_model, technician, status, exrdate, exrtime, exstdate, exstime, deltype, comments, job_cost, part_cost, profit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { $stmt->bind_param("ssssssssssssssss", $customer_name, $customer_email, $customer_phone, $computer_make, $computer_model, $technician, $status, $exrdate, $exrtime, $exstdate, $exstime, $deltype, $comments, $job_cost, $part_cost, $profit); $stmt->execute(); $stmt->close(); if(isset($_POST['send_sms'])): $repair_id = $mysqli->insert_id; $SMS = "Hello ".$customer_name.". Your repair has been booked in with IT Done Right. Your Repair ID is ".$repair_id.". To track your repair, please visit https://www.it-doneright.co.uk/track-my-repair FROM IT Done Right"; function sendSMS($username, $password, $customer_phone, $message, $originator) { $URL = 'https://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; $URL .= "&to=$customer_phone&message=".urlencode($message).'&orig='.urlencode($originator); $fp = fopen($URL, 'r'); return fread($fp, 1024); } $from = ''; $response = sendSMS('', '', $customer_phone, $SMS, $from); if ($stmt = $mysqli->prepare("UPDATE repairs SET send_sms = 1 WHERE id=$repair_id")) { $stmt->execute(); $stmt->close(); } // show an error message if the query has an error else { echo "ERROR: could not prepare SQL statement."; } endif; } // show an error if the query has an error else { echo "ERROR: Could not prepare SQL statement."; } $to = "$customer_email"; $subject = "Booked Repair Information"; $message = " <html> Hello <strong>$customer_name</strong> <h2>Below is your repair details to track the repair status</h2> <p>Your Name: $customer_name</p> <p>Your Email: $customer_email</p> <p>Your Phone Number: $customer_phone</p> <p>PC/Laptop Make: $computer_make</p> <p>PC/Laptop Make: $computer_model</p> <p>Assigned to Technician: $technician</p> <p>Current Repair Status: $status</p> <p>Expected Start Date: " . date('d/m/Y', strtotime($exstdate)) . "</p> <p>Expected Start Time: $exstime</p> <p>Expected Repair Date: " . date('d/m/Y', strtotime($exrdate)) . "</p> <p>Expected Repair Time: $exrtime</p> <p>Dropoff or Pickup: $deltype</p> <p>Comments: $comments</p> <p>Job Repair Cost: " . '£' . $job_cost . "</p> <p>Repair Job ID: " . mysqli_insert_id($mysqli) . " <strong>(Enter this ID number into link below)</strong></p> <p>https://www.it-doneright.co.uk/track-my-repair.php</p> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; $headers .= 'From: <enquiries@it-doneright.co.uk>' . "\r\n"; mail($to,$subject,$message,$headers); // redirec the user header("Location: view-repairs-tracking.php"); } } // if the form hasn't been submitted yet, show the form else { renderForm(); } } // close the mysqli connection $mysqli->close(); ?> Thank you in advance UPDATE: Would something like the following work on each option value? <option value="In Queue" <?php if ($row['status'] == 'In Queue') 'selected = "selected"'; ?>>In Queue</option>
  10. Update: Sorry have got is susses now
  11. I have followed the coding from the link in your post reply but no results are showing when I do a search and what name I am searching for should return 1 result, good thing is I have no errors but not sure what I am missing I have the following code now <?php //load database connection $host = "localhost"; $user = ""; $password = ""; $database_name = ""; $pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )); $search=$_POST['search']; $sql=$pdo->prepare("SELECT select id, fullname, address, emailaddress, phonenumber, mobilenumber, amountloan, term, homeowner, DATE_FORMAT(loanappdate, '%d/%m/%Y') AS 'loanappdate' from unsecured_loans where fullname LIKE '%$search%'"); // Search from MySQL database table $sql->bindValue(1, "%$search%", PDO::PARAM_STR); // were any rows found? if ($row = $sql->fetchObject()) { // display records in a table echo "<table class='records'>"; // set table headers echo "<tr> <th>ID</th> <th>Full Name</th> <th>Address</th> <th>Email Address</th> <th>Phone Number</th> <th>Mobile Number</th> <th>Unsecured Loan Amount</th> <th>Term(Months)</th> <th>Applicant Status</th> <th>Unsecured Loan Application Date</th> <th colspan='1'>Actions</th> </tr>"; do { // set up a row for each record echo "<tr>"; echo "<td>" . $row->id . "</td>"; echo "<td>" . $row->fullname . "</td>"; echo "<td>" . $row->address . "</td>"; echo "<td>" . $row->emailaddress . "</td>"; echo "<td>" . $row->phonenumber . "</td>"; echo "<td>" . $row->mobilenumber . "</td>"; echo "<td>" . '£' . $row->amountloan . "</td>"; echo "<td>" . $row->term . "</td>"; echo "<td>" . $row->homeowner . "</td>"; echo "<td>" . $row->loanappdate . "</td>"; echo '<td><a onClick=\"javascript: return confirm("Are you sure you wish to delete this applicant?");\" href="delete.php?id=" . $row->id . "">Delete</a></td>'; echo "</tr>"; } while ($row = $sql->fetchObject()); echo "</table>"; } // if there are no records in the database, display an alert message else { echo "No results to display!"; } ?>
  12. Hi I am making a search form where the admin can search for a name using a input field and returns the results for records that match the name, that side of it works but I can't get the id record number retrieved from the db and make it a clickable link but I get the following error in the id column Notice: Trying to get property of non-object in /home/firstqualityfina/public_html/admin/unsecured-loan-applicants/search-unsecured-loan-applicant-results.php on line 97 On line 97 is the following echo "<a href='view-specific-unsecured-loan-applicant.php?id=" . $results->id ."'>".$results->id . "</a>"; The whole code looks like the following <?php //load database connection $host = "localhost"; $user = ""; $password = ""; $database_name = ""; $pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )); // Search from MySQL database table $search=$_POST['search']; $query = $pdo->prepare("select id, fullname, address, emailaddress, phonenumber, mobilenumber, amountloan, term, homeowner, DATE_FORMAT(loanappdate, '%d/%m/%Y') AS 'loanappdate' from unsecured_loans where fullname LIKE '%$search%' LIMIT 0 , 10"); $query->bindValue(1, "%$search%", PDO::PARAM_STR); $query->execute(); $query->execute(); // Display search result if (!$query->rowCount() == 0) { echo "<div style='clear: both;'>"; echo "<br><br>"; echo "<table class='records'>"; echo "<thead>"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>Full Name</th>"; echo "<th>Address</th>"; echo "<th>Email Address</th>"; echo "<th>Phone Number</th>"; echo "<th>Mobile Number</th>"; echo "<th>Unsecured Loan Amount</th>"; echo "<th>Term(Months)</th>"; echo "<th>Applicant Status</th>"; echo "<th>Unsecured Loan Application Date</th>"; echo "<th>Actions</th>"; echo "</tr>"; echo "</thead>"; while ($results = $query->fetch()) { echo "<tr><td>"; echo "<a href='view-specific-unsecured-loan-applicant.php?id=" . $results->id ."'>".$results->id . "</a>"; echo "</td><td>"; echo $results['fullname']; echo "</td><td>"; echo $results['address']; echo "</td><td>"; echo $results['emailaddress']; echo "</td><td>"; echo $results['phonenumber']; echo "</td><td>"; echo $results['mobilenumber']; echo "</td><td>"; echo '£' . $results['amountloan']; echo "</td><td>"; echo $results['term']; echo "</td><td>"; echo $results['homeowner']; echo "</td><td>"; echo date("d/m/Y", strtotime($results['loanappdate'])); echo "</td><td>"; echo '<a onClick=\"javascript: return confirm("Are you sure you wish to delete this applicant?");\" href="delete.php?id=<?= $row["id"]; ?>">Delete</a></td>'; echo "</tr>"; echo "</table>"; } } ?> Thank you in advance
  13. Hello I am struggling with some coding, I need a script to check if a url stored in my database is indexed in Google and if it is to display a green check image and if it is not then to display a red cross image, below is the code I have that I found by doing some searching function indexed($url) { $url = 'http://webcache.googleusercontent.com/search?q=cache:' . urlencode($url); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Chrome 10'); if (!curl_exec($ch)) { // var_dump('failed'); return false; } $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // var_dump($code); return $code == '200'; } below is the whole code I have but is displaying an error and all the urls pulled from the database have a red cross but am sure they are indexed in Google ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); // connect to the database include('connect-db.php'); function indexed($url) { $url = 'http://webcache.googleusercontent.com/search?q=cache:' . urlencode($url); $ch = curl_init($url); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Chrome 10'); if (!curl_exec($ch)) { // var_dump('failed'); return false; } $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // var_dump($code); return $code == '200'; } // get the records from the database if ($result = $mysqli->query("SELECT id, category, url, DATE_FORMAT(domain_expiry_date, '%d/%m/%Y') AS domain_expiry_date, site_login_url, site_username_login, site_password_login, no_of_posts, tf, cf, domain_name_owner, DATE_FORMAT(domain_owner_dob, '%d/%m/%Y') AS domain_owner_dob, domain_owner_address, domain_owner_email, domain_owner_phone, email_account, email_account_address, email_username, email_password, registrar, registrar_username, registrar_password, hosting_company, hosting_username, hosting_password, DATE_FORMAT(hosting_expiry_date, '%d/%m/%Y') AS hosting_expiry_date, hosting_cpanel_url, hosting_cpanel_username, hosting_cpanel_password, sites_linked_out_to, DATE_FORMAT(last_post_date, '%d/%m/%Y') AS last_post_date FROM websites")) { // display records if there are records to display if ($result->num_rows > 0) { // display records in a table echo "<table class='records'>"; // set table headers echo '<tr> <th>URL</th> <th>Indexed</th> </tr>'; while ($row = $result->fetch_object()) { $index = indexed($row->url); // set up a row for each record echo "<tr>"; echo "<td class='expand'><a href='http://" . $row->url . "' target='_blank'>" . $row->url . "</a></td>"; echo "<td class='shrink'><img src='images/" . (($index->indexed) ? 'green-check.png' : 'red-cross.png') . "' style='width: 30px; height: 30px;'></td>"; echo "</tr>"; } echo "</table>"; // retrieve and show the data } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli->error; } // close database connection $mysqli->close(); Notice: Trying to get property of non-object in /home/cloudnetworkhero/public_html/network/websites-info/indexed.php on line 54
  14. Hi, I have a update, I have been playing around with the script and have now managed to get it to send the email and update just the records that have dates that are going to expire in 7 days but it don't seem to be looping through to check all dates and include multiple dates in the email, can someone check my coding please as my email only includes one date where as it should include two dates my code is below <?php $db = mysqli_connect("localhost" , "", "") or die("Check connection parameters!"); // Optionally skip select_db and use: mysqli_connect(host,user,pass,dbname) mysqli_select_db($db,"") or die(mysqli_error($db)); if (mysqli_connect_error()) { die ('Failed to connect to MySQL'); } else { /*SUCCESS MSG*/ echo ''; } $sqlCommand = "SELECT u.id , domain_name_owner , url , DATE_FORMAT(domain_expiry_date, '%e %M %Y') as domain_expiry_date , domain_owner_email FROM websites u WHERE domain_expiry_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 7 DAY "; $query = mysqli_query($db, $sqlCommand) or die (mysqli_error($db)); $current_visitor=0; $current_email = ''; $headers = "From: noreply@domain.co.uk\r\n"; $subject = "Domain Name Expiry Date(s)"; $message = ''; //fetch the data from the database while ($row = mysqli_fetch_array($query)) { $arr_ids[] = $row['id']; // has visitor_id changed if ($row['id'] != $current_visitor) { // send email to current visitor if ($current_visitor != 0) { $to = $current_email; $sendmail = mail($to, $subject, $message, $headers); if ($sendmail) { echo nl2br($message); echo "<b>Email Successfully Sent</b><br><br>"; } else { echo "<b>Error in Sending of Email to $to</b><br><br>"; } } $current_visitor = $row['id']; $current_email = $row['domain_owner_email']; $message = "Domain Name Owner: {$row['domain_name_owner']} \n\n"; } $message .= "Your Domain Name {$row['url']} expiry date is: {$row['domain_expiry_date']}\n"; } // send email to final visitor if ($current_visitor != 0) { $to = $current_email; $sendmail = mail($to, $subject, $message, $headers); if ($sendmail) { echo nl2br($message); echo "<b>Email Successfully Sent</b><br><br>"; } else { echo "<b>Error in Sending of Email to $to</b><br><br>"; } if (isset($arr_ids)){ $sql = "UPDATE websites SET date_notified_of_domain_expiry = NOW() WHERE id IN ("; $sql .= implode("," , $arr_ids); $sql .= ");"; print $sql; } //$db->query($sql); $db->query($sql) or die(mysqli_error($db)); // Free the results mysqli_free_result($query); //close the connection mysqli_close($db); } ?>
×
×
  • 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.