
ianhaney10
Members-
Posts
21 -
Joined
-
Last visited
Everything posted by ianhaney10
-
I need some help with getting checkbox values sent to email using phpmailer I have not done it before so unsure how to do it, the current code I have is below $postData = $_POST; $oneway = $_POST['oneway']; $return = $_POST['return']; $htmlContent = '<h2>Contact Form Details</h2> <p><b>One Way:</b> ' . $oneway . '</p> <p><b>Return:</b> ' . $return . '</p> <form action="#errors" method="post" class="formontop"> <div class="booking-form"> <div class="row mb-4"> <div class="col-lg-6"> <div class="form-check"> <input type="checkbox" name="oneway" class="form-check-input" value="<?php echo !empty($postData['oneway'])?$postData['oneway']:''; ?>"> <label class="form-check-label" for="oneway"> One Way </label> </div> </div> <div class="col-lg-6"> <div class="form-check"> <input type="checkbox" name="return" class="form-check-input" value="<?php echo !empty($postData['return'])?$postData['return']:''; ?>"> <label class="form-check-label" for="return"> Return </label> </div> </div> <button class="default-btn" type="submit" name="submit">Get My Quote</button> </div> </div> </form>
-
need access for different account roles on a php page
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Think I just solved it by changing a line to the following if(!isset($_SESSION["account_loggedin"]) || $_SESSION["account_loggedin"] !== true || $_SESSION["account_role"] != 'Member' && $_SESSION["account_role"] != 'Secretary') { -
I have two different user roles, one is Member and the other is Secretary and I need to be able to allow access to a php page if either Member or Secretary is logged in. I originally had the code below which worked if a Member role was logged in <?php session_start(); // If the user is not logged in redirect to the login page... if(!isset($_SESSION["account_loggedin"]) || $_SESSION["account_loggedin"] !== true || $_SESSION["account_role"] != 'Member') { include('includes/baseurl.php'); $title = "Show Diary - The British Rabbit Council"; $pgDesc=""; include ( 'includes/header.php' ); ?> I added the Secretary role to the code but it won't allow me to access the page, I think it's because I'm not logged in as a Member role and am logging as the Secretary role but I need access to the php page if I am logged in as either Member or Secretary The current code I have is below <?php session_start(); // If the user is not logged in redirect to the login page... if(!isset($_SESSION["account_loggedin"]) || $_SESSION["account_loggedin"] !== true || $_SESSION["account_role"] != 'Member' || $_SESSION["account_role"] != 'Secretary') { include('includes/baseurl.php'); $title = "Show Diary - The British Rabbit Council"; $pgDesc=""; include ( 'includes/header.php' ); ?> Can anyone help please, thank you in advance
-
I have some php code that says if index.php or main root then display some code and if not then show other code and it works on index.php but if it's just the domain name without index.php at the end, it don't work. I have the following code at the moment <?php $currentpage = $_SERVER['REQUEST_URI']; if($currentpage=='/' || $currentpage=="/index.php" || $currentpage=="index.php" || $currentpage=="" ) { ?> Can anyone help me out please as I don't know what to amend for the code to work if main root and not have index.php at the end, the code should be the same for the main root / and index.php
-
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Thank you for the code and the other points, I'm not 100% on PDO and would need to re do the whole system in PDO as it's all done in mysqli but for now I'm not sure what the code would be in mysqli to do the dynamically built where clause -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
I have just found this code which is look bit more easier to follow but again bit unsure where it would fit in to the current code <?php $where ="1=1"; if(isset($_POST['Station']) && !empty($_POST['Station']) && $_POST['Station'] !='All') { $where .=" and station = '$Station'"; } if(isset($_POST['Section']) && !empty($_POST['Section']) && $_POST['Section'] !='All') { $where .=" and section= '$section'"; } "SELECT StationName, SectionName FROM profiles WHERE".$where -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
That's where I would get bit stuck, I tried to google it and found code that would work but I'm unsure where in my current code it would go The lorry name is repeated in the sales data on the sales page Instead of this code echo "<option value=\"{$row['lorry']}\" $selected>{$row['lorry']}</option>"; Should I have echo "<option value=\"{$row['id']}\" $selected>{$row['lorry']}</option>"; The code I found online for the all data is below but was unsure to fit that into the current code, obviously it needed amending to be lorryall instead of username or something like that and lorry instead of username but though if can get the code right first then can change the names $username_part = ""; if ($username != 'ALL') { $username_part = "username = '$username' AND"; } $q = "SELECT * FROM reports WHERE $username_part section_name = '$section_name' AND qeblah_status = '$qeblah_status' AND prayer_painting = '$prayer_painting' AND fatwa_status = '$fatwa_status'"; -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Ahh ok, I don't have a value that matches the lorry name called all or All Lorries but be good to show all the lorries within the dates but sounds like it's using all three fields to search for the data, would I possibly then need two sql queries so if select All Lorries then would show all the lorries no matter the dates chosen or if the dates could be left empty and if I choose Basildon Lorry or Wickford Lorry and choose a start and end date then would show the lorry data as it does currently -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
I've attached the whole code in a txt file as thought might be easier to see all the code CURRENT CODE FOR FORUM.txt -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Sorry found the problem , I spotted > was missing at the end of option where it's got </option\n"; I added the > and it's displaying the Wickford Lorry option now and it's working just apart from the All Lorries, it's displaying no data but thought it would show the data for the dates chosen, I can paste the whole code if needed in a txt file -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
I have changed the db password I have also tried the code and it's staying on the selected dropdown value but it's stopped bit of it from working, for example if I select All Lorries, no data is displayed but the dates are correct so thought it would do Also the other bit that is happening is it's not showing the third dropdown value which should say Wickford Lorry, it stops after the Basildon Lorry The basic html code without the PHP is outputted as the following <select name="lorry" id="lorry" class="custom-select select-2"> <option value="all">All Lorries</option> <option>Basildon Lorry</option>Wickford Lorry Date Start </select> The code I have is below <select name="lorry" id="lorry" class="custom-select select-2"> <option value="all">All Lorries</option> <?php $mysqli = new mysqli('localhost', '', '', ''); $sql = "SELECT id, lorry FROM lorries"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $sel = ($row['lorry'] == $_GET['lorry']) ? 'selected' : ''; echo "<option $sel >{$row['lorry']}</option\n"; } } ?> </select> -
php select dropdown values with selected
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Dam it, I forgot to remove the db info I normally remove the db crendentials before posting but bit stressed today, I'll change the db password I'll try that code though and post a update, thank you for the code. I'll post a update once tried in a few mins -
I have been making a select dropdown that populates with values from a database table and got that working and on the page, it's a sales report page so I select the dropdown option value I want then put the dates in and click filter and it shows the results in a table below the form fields and it's working but when the page refreshes after clicking filter, the select dropdown resets and go back to the very first option in the select dropdown, I have tried to add selected to the option value but I am not doing it right as the vales don't have selected in the inspect element code but that may be because the page is refreshing The current select dropdown code is below as thought that may be only part that's relevant to my post but can paste the whole code as a txt file if needed <select name="lorry" id="lorry" class="custom-select select-2"> <!--<option value="all">All Lorries</option>--> <?php $mysqli = new mysqli('localhost', 'wwwbeechwoodsolu_collrystmusr', '********', 'wwwbeechwoodsolu_coal-lorry-system'); $sql = "SELECT id, lorry FROM lorries"; $result = $mysqli->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { ?> <option value="<?php echo $row["lorry"]; ?>" <?php echo ($id == $row['id'])? 'selected="selected"':'' ?>><?php echo $row['id'] . ' ' . $row["lorry"]; ?></option> <?php } } ?> </select>
-
Ahh ok, below is the same text with the html tags <h2 class="productsummaryheading mb-0">Product Summary</h2> <br> <br> This 11.6” Chromebook is light, portable, rugged, and productive – the ultimate everyday learning tool. It brings Google Classroom, G Suite for Education, and today’s ...<a href="/shop/laptops-tablets/Laptops/lenovo-100e-chromebook-g2-laptop-11-6-celeron-n4020-4gb-32gb-emmc-webcam-wi-fi-no-lan-usb-c-chrome-os#productdescription">Read More</a> The <h3 tags are already removed, just leaves the other tags I want to remove such as the two <br> tags and the whitespace/ code. Hopefully that helps and explains it bit better
-
Thank you so much for the reply, I did try functions and they don't seem to work properly in the .tpl file. I tried your code above but still got the br tags showing still unfortunately in the text at the beginning
-
I have text that is displayed from a database and I have managed to remove the first h3 tag in the text by using the following code but I would also like to remove the two <br> tags that are before the paragraph of text <h2 class="productsummaryheading mb-0">Product Summary</h2> <?php $html= substr($description,0,strrpos(substr($description,0,300)," ")); $final = preg_replace('#<h3>(.*?)</h3>#', '', $html, 1); echo $final; ?> ...<a href="<?php echo $_SERVER["REQUEST_URI"]; ?>#productdescription">Read More</a> A example of the text paragraph is below <br /> <br /> This 11.6” Chromebook is light, portable, rugged, and productive – the ultimate everyday learning tool. It brings Google Classroom, G Suite for Education, and today’s ...<a href="/shop/laptops-tablets/Laptops/lenovo-100e-chromebook-g2-laptop-11-6-celeron-n4020-4gb-32gb-emmc-webcam-wi-fi-no-lan-usb-c-chrome-os#productdescription">Read More</a>
-
Display specific html tag on specific pages
ianhaney10 replied to ianhaney10's topic in PHP Coding Help
Just got it working with the following code <?php $currentpage = $_SERVER['REQUEST_URI']; if($currentpage=="/" || $currentpage=="/index.php" || $currentpage=="/index" || $currentpage=="" || $currentpage=="/computer-shop-basildon.php" || $currentpage=="/computer-shop-basildon" ) { echo '<section class="testimonal-two pt-0">'; } else { echo '<section class="testimonal-two">'; } ?> -
I want to display different html tags on the php page they are visiting, for example on the homepage and the computer shop basildon page I want the html tag <section class="testimonal-two pt-0"> and on all other pages I want the code <section class="testimonal-two"> Below is the code I have so far and it works for the computer shop basildon page but I'm unsure how to add the homepage into that code, the homepage is called index.php <?php if ($_SERVER["SCRIPT_NAME"] == '/computer-shop-basildon.php') { echo '<section class="testimonal-two pt-0">'; } else { echo '<section class="testimonal-two">'; } ?>
-
I think it might be to do with the following section of code but not 100% sure foreach ($results as $result) { if ($result['category_id']==-1) continue; //foreach ($results as $result) { $filter_data = array( 'filter_category_id' => $result['category_id'], 'filter_sub_category' => true ); $data['categories'][] = array( 'name' => $result['name'] . ($this->config->get('config_product_count') ? ' (' . $this->model_catalog_product->getTotalProducts($filter_data) . ')' : ''), 'href' => $this->url->link('product/category', 'path=' . $this->request->get['path'] . '_' . $result['category_id'] . $url) ); }
-
I have a opencart 2.3 store and I have downloaded a extension that shows all products on one page, it creates a category called All and displays all products in that category. It's working all ok but I would like to have the product filter displayed in the left column so it's the same as the other categories. For example the category here https://www.beechwoodsolutions.co.uk/sites/simply-heavenly-foods/index.php?route=product/category&path=271 has the product filter in the left column. On the all products category page here https://www.beechwoodsolutions.co.uk/sites/simply-heavenly-foods/index.php?route=product/category&path=-1 I would like to have the product filter displayed. The extension I downloaded is https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=29713. I have contacted the developer but don't think they are active anymore so was seeing if anyone was able to help please. I can send over the category.php file/code but it's quite abit of code.
-
I have some php code on view invoice and it's getting all the data I need to from three database tables but for some reason it's not getting the data for one specific column and unsure why I have done a echo sql and it is echoing the sql query ok and have ran the sql query in phpmyadmin and is displaying the column in phpmyadmin that is not displaying on the php page so am bit confused, below is the coding I have. I took out a lot of it and tried to keep to the relevant parts <?php $sql = "SELECT t1.id, t1.invoice_number, DATE_FORMAT(t1.invoice_date,'%d/%m/%Y') AS invoice_date, t1.user_id, t2.invoice_number, t2.service_name, t2.service_price, t3.user_id, t3.customer_name, t3.customer_phone, t3.customer_email, t2.service_name, t2.service_price, t1.invoice_total, t1.balance, t1.notes, DATE_FORMAT(t1.payment_date,'%d/%m/%Y') AS payment_date, t1.payment_method FROM invoices as t1 LEFT JOIN invoice_products as t2 ON t1.id = t2.invoice_id LEFT JOIN users as t3 ON t1.user_id = t3.user_id WHERE t1.user_id = '".$_SESSION['user_id']."' and t1.id = '".$_GET['id']."'"; $result = mysqli_query($connect, $sql); if(mysqli_num_rows($result) > 0) { if($row = mysqli_fetch_array($result)) { ?> Notes: <?php echo $row['notes'];?> <?php } } ?>