Jump to content

rickphp

Members
  • Posts

    27
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

rickphp's Achievements

Member

Member (2/5)

0

Reputation

  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 = "bob@test.com"; $to = "blah@example.co.uk"; $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 = "removed@gmail.com"; $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!
  5. Hi, Just looking for some help. The code is part of a mobile redirection script, to redirect certain user agents to a mobile page. The GETs are being used to allow mobile users to override the mobile redirection so they can view the desktop site on their mobile by setting a session that disables the redirection. I have the following code, which works however I have some niggles/concern. 1) Could the script be used to inject code onto my site, as there is no sanitising on the GET funcitons. 2) When using the GET function, sometimes ?goclient=true / ?gohome=true is appended to the url even though it has redirected them to the correct page. 3) There are two different links to the normal desktop site, one to the home page, and another that goes straight to the client login page. Is it a problem using the same session name? 4) Can I put the 'if ( $_GET['gohome'] != 'true' ) and if ( $_GET['goclient'] != 'true' ) into one statement, as i did them seperately. 5) Is there a way to tidy up the code? At the moment the if statements are seperate out, perhaps it can be coded more efficiently? Obviously this isn't the full code, and the list of vars has been shortened to iphone and ipod - really there are over 30 vars. Any help is greatly appreciated! // redirect to mobile site because session doesnt exist if ( $_GET['gohome'] != 'true' ) { if ($iphone || $ipod) { if (!isset($_SESSION['moboverride'])) { header('Location: http://www.site.com/mobile/'); } } } // redirect to mobile site because session doesnt exist if ( $_GET['goclient'] != 'true' ) { if ($iphone || $ipod) { if (!isset($_SESSION['moboverride'])) { header('Location: http://www.site.com/mobile/'); } } } // redirection override session exists and url contains ?goclient=true, so redirect to client login page, dont redirect to mobile if ( $_GET['goclient'] == 'true' ) { if ($iphone || $ipod) { if (!isset($_SESSION['moboverride'])) { $_SESSION['moboverride'] = true; header('Location: http://www.site.com/clientarea.php'); } } } // redirection override session exists and url contains ?gohome=true, so redirect to normal home page, dont redirect to mobile if ( $_GET['gohome'] == 'true' ) { if ($iphone || $ipod) { if (!isset($_SESSION['moboverride'])) { $_SESSION['moboverride'] = true; header('Location: http://www.site.com/'); } } }
  6. Thank you very much for that. One question though, what is this code for? for($i = 0; $i < 50000; $i++) { Its confuzzled me a bit.. Would it work like this? <?php $handle = fopen('time.txt', 'r'); $old_time = fread($handle, 10); fclose($handle); $now_time = time(); $final_time = ($now_time - $old_time); if($final_time > 30) { function would go here.. }else{ echo 'You must wait';die; } $time_end = time(); $handle = fopen('time.txt', 'w'); fwrite($handle, $time_end, 10); fclose($handle); ?>
  7. Hi, I need a basic if function to run based on time. How it will work is, the script is called. If the script was ran in the last 30 seconds then nothing happens, else it carries out the function. The last access time would have to be stored so the script could see if the current time is more than 30 seconds past the time in the file, a simple text file would be sufficient for this. Can anyone advise how I'd achieve this? Thanks for any help!
  8. Hi, If I need to put commas within a variable how can this be achieved? i.e. if statement..... { $output = "text1,text2,text3"; Incase your wondering what I'm trying to do.. basically im using a header file on my site... i want different keywords within the meta tags depending on the page the user is on, so i want to include aprox 20 keywords in the $output which will be inserted in the comma area of the meta tags. Probably quite an easy way to do it but I'm not sure how to do it! Any help appreciated!
  9. $email is inputted via a form, I think its this bit of coding thats causing the problem as when I remove this bit of code the problem goes away, but I need to ensure proper emails are entered. Any ideas? The form consists of name, businessname, email, phonenumber and message, the problem arrises when the person fills out their email, they can leave the message field empty and the form still sends, if they dont enter an email and only enter a phone number (which is acceptable) they then need to enter a message before the form sends (which again is correct) but its only when entering an email the rest of the validation following the code provided stops working. I think the way I've coded it is halting any following validation.. but only when an email is inputted
  10. I need it so that if the email field isn't blank then the validation be ran against it, but the form is sending even when the message is left empty even though the validation in place is correct, I think the way the below is coded is causing the issue, can it be improved? Here is the current code I've got: else if ($email != "") { if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $error = "The format of your email address is not valid."; } } Sorry if thats not clear enough but hopefully you get what I mean! Thanks for any help!
  11. The w3c validator is showing this error: .min-width Value Error : width Parse Error expression(((document.documentElement.clientWidth | document.body.clientWidth) 1005)? "1005px" : "100%") The line in question is .min-width {width:expression(((document.documentElement.clientWidth || document.body.clientWidth) < 1005)? "1005px" : "100%"); min-width:1005px; background:url(img/bg-top.gif) top repeat-x; } Can anybody help resolve this one? Thanks!
  12. Not heard anything back, did you get the message? If anyone else could help I would really appreciate it as mikesta707 has just gone offline. Thanks in advance!
×
×
  • 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.