Jump to content

rickphp

Members
  • Posts

    27
  • Joined

  • Last visited

Everything posted by rickphp

  1. Thanks for the reply. So I tried those two changes, changing the header didn't seem to resolve it, and replacing mail as you suggested seemed to trigger the last part of the code, as it redirected me to the page saying it hadn't sent. Its interesting, as the mail function works using the example provided in my first post, so it doesn't seem to be the web server rejecting the messages (but I understand what you are thinking). It must be the poorly written code (which I inherited by the way!). I am really out of touch with coding these days. Anyone have any other ideas?
  2. Hi guys, Hope you can help. I've moved a word press site from one cPanel host to another. Since doing so the contact form doesn't work. The PHP versions are the same, with similar modules and php settings. The issue is, the form appears to send properly from the site, but the email never actually arrives. I tried changing the email its sending to, to a gmail account, a hotmail etc. To make sure the server use the mail() function i did the below and received the email straight away: <?php ini_set( 'display_errors', 1 ); error_reporting( E_ALL ); $from = "[email protected]"; $to = "[email protected]"; $subject = "PHP Mail Test script"; $message = "This is a test to check the PHP Mail functionality"; $headers = "From:" . $from; mail($to,$subject,$message, $headers); echo "Test email sent"; ?> Here is the code to process the contact form, I've changed the email address for obvious reasons! Also, the eregi function is deprecated but not sure how to replace it with the new email validation function, if someone could help with that too that'd be awesome. I removed the eregi check to ensure that wasn't causing the issue just FYI. <?php if(trim($_POST['checking']) !== ''){ $capchaError = true; } else { if(trim($_POST["name"]) === ''){ $formError = true; } else { $name = trim($_POST['name']); } if(trim($_POST["email"]) === '') { $formError = true; } elseif (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST["email"]))) { $formError = true; } else { $email = trim($_POST['email']); } if(trim($_POST["number"]) === '') { $formError = true; } else { // validate phone to be either 10 or 11 digits $number = trim($_POST["number"]); $pattern = "/(((\+44)? ?(\(0\))? ?)|(0))( ?[0-9]{3,4}){3}/"; // allows for numbers 8 - 12 digits in length, starting 0 or +44 $match = preg_match($pattern,$number); if ($match === 0) { // if validation fails $formError = true; } else { // if valiudation passes $phone = trim($_POST["number"]); } } if(trim($_POST["subject"]) === ''){ $formError = true; } else { $msgSubject = trim($_POST['subject']); } if(trim($_POST["message"]) === '') { $formError = true; } else { if(function_exists("stripslashes")) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } if($formError !== true) { $email_to = "[email protected]"; $subject = "Message from the website"; $message = 'Name: '. $name . "\n\nPhone: " . $phone . "\n\nEmail: " . $email . "\n\nSubject: " . $msgSubject. "\n\nMessage: " . $comments; $headers = 'From: '.$name.' <'.$email.'>'; mail($email_to, $subject, $message, $headers); $sent = true; } if(isset($sent) && $sent == true) { header("Location: /thank-you/"); } else { header("Location: /message-not-sent/"); } } if($capchaError == true) { header("Location: /message-not-sent/"); } ?> The code for the form on the contact page is as follows (some details changed again): <form action="http://www.site.co.uk/wp-content/themes/site/php/contactprocess.php" id="contact" method="post" class="threeQuarter"> <input type="text" id="name" name="name" placeholder="Name" required> <input type="email" id="email" placeholder="Email" name="email" required> <input type="tel" id="number" placeholder="Number" name="number" required> <input type="text" id="subject" placeholder="Subject" name="subject" required> <textarea id="message" placeholder="Message" name="message" required></textarea> <span id="screenReader">Spam Protection - <i>Do not enter anything in this field</i> <input type="text" name="checking" class="checking" placeholder="Ignore" value="" /> </span> <button class="button fifth" name="serviceFormOne" type="submit">Send</button> </form> Thanks for any help.
  3. Thanks for your reply. That seems to return the following error: Parse error: syntax error, unexpected '=', expecting ')' in /home/galaxy/public_html/includes/hooks/header.php on line 16 Also I'm not quite sure the logic is correct, the idea is to put something like this in the title tags on the header file i.e. <title>{$pagetitle}</title>, obviously the {$pagetitle} bit would come from the hook, which would contain a list of page titles for each page, it does mean i have a list of variables for each page title, but theres only 20 or so, so its not too bad. Thanks Ricky
  4. I am looking to update whmcs from 5.3.x to 6 however some of my template files contain {php} tags... I tried enabling the legacy php tag support within whmcs but it doesn't help - none of the php tags are parsed on a test copy of the site. I have found this article which suggests the php code needs to be loaded through a hook http://docs.whmcs.com/Templates_and_Custom_PHP_Logic, but I can't quite grasp what is required to get it working. Heres an example.. if someone can explain how this would work within a hook I think I can figure the rest out on my own! {php} if( $qrystr = strpos( $_SERVER['REQUEST_URI'], '?' ) ) $url = substr( $_SERVER['REQUEST_URI'], 0, $qrystr ); elseif( $qrystr = strpos( $_SERVER['REQUEST_URI'], '#' ) ) $url = substr( $_SERVER['REQUEST_URI'], 0, $qrystr ); else $url = $_SERVER['REQUEST_URI']; $titleprefix = "Title"; $titledefault = "$titleprefix - blah blah blah"; $title[$url]="$titledefault"; $title["/"]="$titledefault"; $title["/index.php"]="$titledefault"; $title["/affiliates.php"]="$titleprefix - Affiliates"; {/php} and so on.... for each page. and there are further lines for other functions like setting meta tags and robots prefs, but they are the same format as above.. Thanks for any help!
×
×
  • 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.