Skip to main content
Jane W Loanfinder
Known Participant
November 8, 2016
Question

Why does the form not show a success outcome

  • November 8, 2016
  • 0 replies
  • 205 views

This temporary page - Get started. Enquire here for Loanfinder Business Loans.

When data is entered correctly into the form, it is throwing a code error instead of a success outcome which should be to re-direct to another page (Article Description ) and send the email as coded.

I ran the page through an error checker - Showing results for http://www.loanfinder.com.au/formtest2.php - Nu Html Checker , but cannot understand the results.

The current code is :

<?php
require_once "includes/PHPMailerAutoload.php";
   function sanitisedPost($namedIndex) {
      if (!isset($_POST[$namedIndex])) {
         // post field not set
         return null;
      }
     
      return htmlentities($_POST[$namedIndex]);
   }
  
   if (isset($_POST["submit"])) {
      // lets handle all of the form processing only if the form has been submitted
      $name = sanitisedPost('name');
      $email = $_POST['email'];
      $phone = sanitisedPost('phone');
      $businessName = sanitisedPost('businessName');
      $state = sanitisedPost('state');
      $TimeInBusiness = sanitisedPost('TimeInBusiness');
      $LoanSize = sanitisedPost('LoanSize');
      $PrivacyCheck = sanitisedPost('PrivacyCheck');
     
     
      //valid address on your web server
      $from = 'loan@loanfinder.com.au';
      //your email address where you wish to receive mail
      $to = 'loan@loanfinder.com.au';
      $subject = 'Loan Enquiry';
      $body = "From: $name\n
                E-Mail: $email\n
                Phone: $phone\n
                Business Name: $businessName\n
                State: $state\n
                Time In Business: $TimeInBusiness\n
                Loan Size: $LoanSize\n
                Privacy Check: $PrivacyCheck\n";
     
     
      $errors = array();
      if ($name == null || strlen($name)==0) {
         $errors[] = "Please enter your name";
      }
     
      if ($TimeInBusiness==null) {
         $errors[] = "Time in business not set";
      }
     
      if ($PrivacyCheck==null) {
         $errors[] = "Privacy Check not set";
      }
     
      if ($email == null || strlen($email)==0) {
         $errors[] = "Please enter your email address";
      } else {
         if (!filter_var($email,FILTER_VALIDATE_EMAIL)) {
            $errors[] = "Please enter a valid email address";
         }
      }
      // Check if phone is entered
      if ($phone == null || strlen($phone)<10) {
         $errors[] = "Please enter your phone number";
      }
     
     
      // If there are no errors, send the email & output results to the form
      if (!count($errors)) {
         $mail = new PHPMailer();
        
         $mail->IsSMTP();
         $mail->Host = "launch.server101.com";
         $mail->Port = 25;
         $mail->SMTPDebug  = 1;
         $mail->setFrom($from,"Form Submission");
         $mail->addAddress($to, $name);
         $mail->Subject = $subject;
         //$mail->msgHTML($body);
         $mail->AltBody = $body;
        
         if ($mail->send()) {
            $result = '<div class="alert alert-success"><h2><span class="glyphicon glyphicon-ok"></span> Message sent!</h2><h3>Thank you for contacting us. Someone will be in touch with you soon.</h3></div>';
           
            // if you wish to redirect the page:
            header("Location: http://www.loanfinder.com.au/Thankyou.html");
         } else {
            $result = '<div class="alert alert-danger"><h2><span class="glyphicon glyphicon-warning-sign"></span> Sorry there was a form processing error.</h2> <h3>Please try again later.</h3></div>';
         }
      } else {
         $errors = implode(", ",$errors);
         $result = '<div class="alert alert-danger"><h2><span class="glyphicon glyphicon-warning-sign"></span> Sorry there was a form processing error. The errors returned were: '.$errors.'</h2> <h3>Please try again later.</h3></div>';
      }
      echo $result;
      return;
   }

?>

<!DOCTYPE html>
<html lang="en">
  
  
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>Get started. Enquire here for Loanfinder Business Loans.</title>
      <meta name="description" content="Get started here. Loanfinder Business Loans. Loans approved and funded quickly for business based on your cashflow.">
      <meta name="robots" content="index,follow">
      <!-- Bootstrap -->
      <link href="css/bootstrap.css" rel="stylesheet">
      <link href="styles.css" rel="stylesheet" type="text/css">
     
     
      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
      <![endif]-->
   </head>
  
  
   <body>
      <div class="container-fluid" id="wrapper">
         <!--top nav-->
         <nav class="navbar navbar-default navbar-fixed-top" id="navbar" role="navigation">
            <div class="container-fluid">
               <div class="navbar-header">
                  <a class="navbar-brand" href="#">
                     <a href="index.html"><img src="Images/Logo2.jpg" width="185" height="51" alt=""/></a>
                  </a>
                 
                 
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                     <span class="icon-bar"></span>
                  </button>
              
              
               </div>
              
              
               <div class="collapse navbar-collapse navprop" id="myNavbar">
                  <ul class="nav navbar-nav navbar-right">
                     <li><a href="Resources.html">1800 090 555 </a></li>
                     <li><a href="index.html">Home</a></li>
                     <li><a href="How it works.html">How it works</a></li>
                     <li><a href="questions.html">Questions</a></li>
                     <li><a href="Resources.html">Resources</a></li>
                  </ul>
               </div>
            </div>
        
        
         </nav>
         <!--end top nav-->
        
        
         <div class="container">
            <p></p>
            <p></p>
            <p></p>
            <h1 class="text-center"><strong>Get Started</strong></h1>
            <p></p>
            <h5>How do I apply?</h5>
            <p>Complete the quick form below and a loan consultant will contact you to discuss your requirements.</p>
            <p>Our privacy policy can be found <a href="Privacy Policy.html">here</a></p>
            <p></p>
           
            <style>
               .required {
                  color: red;
                  font-weight: bold
               }
              
               .center-block {
                  float: none
               }
              
               .human {
                  margin: 0 0 0 12px
               }
            </style>
            <div class="container-fluid">
               <div class="col-md-8 center-block">
                 
                 
                  <h3>The smart way to finance your business</h3>
                  <p class="required small">Grow your business and manage your cash flow with an unsecured business loan. </p>
                  <p> </p>
                  <p> </p>
                 
                  <!--begin HTML Form-->
                  <form class="form-horizontal" method="post" action="">
                    
                    
                     <div class="form-group">
                        <label for="name" class="col-sm-3 control-label"><span class="required">*</span> First Name:</label>
                        <div class="col-sm-5">
                           <input type="text" class="form-control" id="name" name="name" placeholder="First Name">
                        </div>
                     </div>
                    
                    
                     <div class="form-group">
                        <label for="email" class="col-sm-3 control-label"><span class="required">*</span> Email: </label>
                        <div class="col-sm-5">
                           <input type="email" class="form-control" id="email" name="email" placeholder="you@domain.com">
                        </div>
                     </div>
                    
                    
                     <div class="form-group">
                        <label for="phone" class="col-sm-3 control-label"><span class="required">*</span> Phone Number: </label>
                        <div class="col-sm-5">
                           <input type="tel" class="form-control" id="phone" name="phone" placeholder="0400 000 000 or 02 1234 5678">
                        </div>
                     </div>
                    
                    
                     <div class="form-group">
                        <label for="Business Name" class="col-sm-3 control-label"> Business Trading Name</label>
                        <div class="col-sm-7">
                           <input class="form-control" row="4" name="businessName" placeholder="Business / Company Name">
                        </div>
                     </div>
                     <div class="form-group">
                        <label for="State" class="col-sm-3 control-label"> Select your State</label>
                        <div class="col-sm-9">
                           <select name="state" class="col-sm-3 control-label">
                              <option value="">Select</option>
                              <option value="NSW">NSW</option>
                              <option value="QLD">QLD</option>
                              <option value="VIC">VIC</option>
                              <option value="WA">WA</option>
                              <option value="SA">SA</option>
                              <option value="NT">NT</option>
                              <option value="ACT">ACT</option>
                              <option value="OTHER">Other</option>
                           </select>
                       
                       
                        </div>
                     </div>
                     <p> </p>
                     <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-6 col-sm-offset-3">
                           <p class="required">Time in Business
                           </p>
                           <p>
                              <label>
                                 <input type="radio" name="TimeInBusiness" value="radio" id="Lessthan6months">
                                 Less than 6 months</label>
                              <br>
                              <label>
                                 <input type="radio" name="TimeInBusiness" value="radio" id="6to12months">
                                 6 to 12 months</label>
                              <br>
                              <label>
                                 <input type="radio" name="TimeInBusiness" value="radio" id="Over1year">
                                 Over 1 Year</label>
                              <br>
                           </p>
                           <p class="required">Loan Amount Required
                           </p>
                           <p>
                              <label>
                                 <input type="radio" name="LoanSize" value="radio" id="upto$50K">
                                 $5K to $50K</label>
                              <br>
                              <label>
                                 <input type="radio" name="LoanSize" value="radio" id="upto$250K">
                                 $50K to $250K</label>
                              <br>
                              <label>
                                 <input type="radio" name="LoanSize" value="radio" id="over$250K">
                                 Over $250K</label>
                              <br>
                           </p>
                           <p> </p>
                           <div class="form-group">
                              <p>
                                 <label>
                                    <input type="checkbox" required name="PrivacyCheck" value="checkbox" id="PrivacyCheck">
                                    I have reviewed, understand and consent to the privacy policy</label>
                                 <br>
                              </p>
                             
                             
                              <button type="submit" id="submit" name="submit" class="btn-lg btn-primary btn-block">SUBMIT (Free and No obligation)</button>
                           </div>
                        </div>
                        <!--end Form-->
                  </form>
                  <!--end col block-->
               </div>
           
           
            </div>
            <p> </p>
            <p> </p>
            <p>You can also send a quick email to <a href="mailto:loan@loanfinder.com.au">loan@loanfinder.com.au</a> with details on what you require.</p>
            <p> </p>
            <p> </p>
            <p>If you want to make the process faster, send an email to
               <a href="mailto:loan@loanfinder.com.au">loan@loanfinder.com.au</a> with a copy of your last 3 months business bank statements and a copy of your drivers licence.</p>
            <p></p>
            <!-- BEGIN: Constant Contact Email List Form Button -->
            <div align="center">
               <a class="button" style="padding: 8px 10px; border-radius: 20px; border: 1px solid rgb(91, 91, 91); border-image: none; color: rgb(255, 255, 255); display: inline-block; text-shadow: none; background-color: rgb(0, 103, 206);" href="https://visitor.r20.constantcontact.com/d.jsp?llr=4iis56yab&p=oi&m=1126286565663&sit=kjojhralb&f=479f0d50-5f6a-450b-bf3e-b7f9c3045a86">Keep Updated</a>
               <!-- BEGIN: Email Marketing you can trust -->
               <div align="center" id="ctct_button_footer" style="color: rgb(153, 153, 153); font-family: Arial,Helvetica,sans-serif; font-size: 10px; margin-top: 10px;">Keep yourself updated and informed. Add your email here.</div>
            </div>
            <p></p>
            <p></p>
            <p></p>
            <p></p>
            <p></p>
            <div class="container-fluid"></div>
            <footer>&copy;Copyright 2016 Loanfinder Pty Ltd</footer>
         </div>
      </div>
      <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
      <script src="js/jquery-1.11.3.min.js"></script>
     
     
      <!-- Include all compiled plugins (below), or include individual files as needed -->
      <script src="js/bootstrap.js"></script>
      <script>
         (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r;
            i = i || function () {
                  (i.q = i.q || []).push(arguments)
               }, i.l = 1 * new Date();
            a = s.createElement(o)
               , m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            m.parentNode.insertBefore(a, m)
         })(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
        
        
         ga('create', 'UA-86438859-1', 'auto');
         ga('send', 'pageview');
      </script>
   </body>

</html>

    This topic has been closed for replies.