Jump to content

ianhaney10

Members
  • Posts

    24
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ianhaney10's Achievements

Member

Member (2/5)

0

Reputation

  1. Thank you, I'm trying a different way until can sort the other email address out. a gmail email address has been set up and trying that and from what I read online, a app password needs to be created and use that within phpmailer settings instead of the password used to create the email address
  2. Ahh ok sounds like it could be that and silently accepting emails. It's on the web hosting with hostgator. It's in the web hosting cPanel but it still don't seem to be sending, I'm using my email address at the moment as a test and it's not coming through so for some reason it don't seem to be sending the email
  3. Hi I am trying to use phpmailer without the smtp credentials as the client does not know the email password or they don't have it to hand so trying to use phpmailer without the smtp info, I am trying the following code and not getting any errors and it's going to the enquiry confirmation page but the email is not coming through <?php session_start(); use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; // Include PHPMailer 6.x autoloader require 'PHPMailer/src/Exception.php'; require 'PHPMailer/src/PHPMailer.php'; require 'PHPMailer/src/SMTP.php'; $name = ''; $phone = ''; $email = ''; $message = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $message = $_POST['message']; $error=''; if(!$name || !$phone || !$email || !$message){ $error.="**Please fill the fields.!".'<br>'; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error.="**Please enter valid email address.".'<br>'; } if(!$error){ // Initialize PHPMailer $mail = new PHPMailer(true); try { $mail->SMTPDebug = 0; // Enable verbose debug output / Enable SMTP debug information (for testing) //$mail->isSMTP(); // Set mailer to use SMTP //$mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers //$mail->SMTPAuth = true; // Enable SMTP authentication //$mail->Username = ''; // SMTP username //$mail->Password = ''; // SMTP password //$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted //$mail->Port = 587; // TCP port to connect to $mail->setFrom('[email protected]', "Company Name"); $mail->addAddress('[email protected]', "Company Name"); // Add a recipient $mail->addReplyTo($_POST['email'], $_POST['name']); $mail->isHTML(false); // Set email format to HTML $mail->Subject = 'New Website Enquiry'; $mail->Body = "A new website enquiry has been made. The enquiry information is below\r\n\r\n" . "Name: " . $_POST["name"] . "\r\n" . "Phone: " . $_POST["phone"] . "\r\n" . "Email: " . $_POST["email"] . "\r\n" . "Message: " . $_POST["message"]; $mail->send(); // Redirect upon successful sending header("Location: http://domainname.co.uk/enquiry-confirmation.php"); exit(); } catch (Exception $e) { echo 'Message could not be sent.'; echo 'Mailer Error: ' . $mail->ErrorInfo; } } } ?> <form action="#form-section" method="post"> <div class="row"> <div class="col-sm-6 col-lg-6"> <div class="form-group"> <input type="text" value="<?php echo $name; ?>" name="name" id="name" class="form-control" required placeholder="Name"> </div> </div> <div class="col-sm-6 col-lg-6"> <div class="form-group"> <input type="text" value="<?php echo $phone; ?>" name="phone" id="phone" class="form-control" placeholder="Phone"> </div> </div> <div class="col-sm-12 col-lg-12"> <div class="form-group"> <input type="email" value="<?php echo $email; ?>" name="email" id="email" class="form-control" required placeholder="Email"> </div> </div> <div class="col-md-12 col-lg-12"> <div class="form-group"> <textarea name="message" class="form-control" cols="30" rows="8" required placeholder="Message" value="<?php echo $message; ?>"></textarea> </div> </div> <div class="col-md-12 col-lg-12"> <button type="submit" id="submit" name="submit" class="contact-btn btn">Send Message</button> <div class="clearfix"></div> </div> </div> </form> Can anyone see where I have gone wrong please as been trying for hours and can't see what the issue is
  4. 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>
  5. 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') {
  6. 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
  7. 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
  8. 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
  9. 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
  10. 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'";
  11. 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
  12. 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
  13. 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
  14. 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>
  15. 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
×
×
  • 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.