Jump to content

dlcmpls

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Posts posted by dlcmpls

  1. Jesi you are a saint.  I can't tell you how much I appreciate your help.  In trying to get this to work, I've tried to reduce the code to the bare minimum.  Anyway, here's a repaste of the code (and yep, this is all the code):

     

    <?php

     

    function clean($text) {

      return strip_tags($text);

    }

     

     

    $firstname = clean('Dave <br>');

     

     

    clean();

    ?>

     

    The  $firstname = clean  is all on one line.

     

    I tightened up the code a bit so the new error message is:

     

    Parse error: parse error in /Library/WebServer/Documents/php_default_website/dev/contact_us/test.php on line 3

     

     

    Line 3 is: return strip_tags($text);

  2. Hello everyone.  I'm trying to write my first function and having all kinds of trouble.

     

    Here's what I've got so far:

     

    <?php

     

    function clean($text) {

      return strip_tags($text);

    }

     

     

    $firstname = clean('Dave <br>');

     

     

    clean();

    ?>

     

    I am basically just trying to get the function to remove any html from a variable, but I get this error message:

     

    Parse error: parse error in /Library/WebServer/Documents/php_default_website/dev/contact_us/test.php on line 7

     

    Any suggestions?

     

    dlc

  3. Hello everyone.  I wrote a bit of code to thwart spammers trying to hijack my form processing script.  I have 3 files in play...1 form that a user fills out, a form processor, and a Thank You page.

     

    I have a question about code in my form processor.  Here's a bit of the code in question:

     

    //get the variables posted from the form

    $firstname = $_POST['FirstName'];

    $lastname = $_POST['LastName'];

    $organization = $_POST['OrgName'];

    $address1 = $_POST['Address1'];

    $address2 = $_POST['Address2'];

    $city = $_POST['City'];

    $state = $_POST['State'];

    $zip = $_POST['Zip'];

    $phone = $_POST['Phone'];

    $phonehome = $_POST['PhoneHome'];

    $phonework = $_POST['PhoneWork'];

    $phonecell= $_POST['PhoneCell'];

    $email = $_POST['Email'];

    $message = $_POST['Message'];

    //FOLLOWING ITEM IS USED FOR EMAIL FRIEND FEATURE

    $senderemail = $_POST['SenderEmail'];

     

     

    ////////  TRIM THE ENDS OF THE STRING TO REMOVE ANY EMPTY SPACES

    $firstname = trim($firstname);

    $lastname = trim($lastname);

    $organization = trim($organization);

    $address1 = trim($address1);

    $address2 = trim($address2);

    $city = trim($city);

    $state = trim($state);

    $zip = trim($zip);

    $phonehome = trim($phonehome);

    $phonework = trim($phonework);

    $phonecell= trim($phonecell);

    $email = trim($email);

    $phone = trim($phone);

    $message = trim($message);

    $senderemail = trim($senderemail);

     

    ////////  STRIP HTML AND PHP TAGS FROM THE STRINGS

    $firstname = strip_tags($firstname);

    $lastname = strip_tags($lastname);

    $organization = strip_tags($organization);

    $address1 = strip_tags($address1);

    $address2 = strip_tags($address2);

    $city = strip_tags($city);

    $state = strip_tags($state);

    $zip = strip_tags($zip);

    $phonehome = strip_tags($phonehome);

    $phonework = strip_tags($phonework);

    $phonecell= strip_tags($phonecell);

    $email = strip_tags($email);

    $phone = strip_tags($phone);

    $message = strip_tags($message);

    $senderemail = strip_tags($senderemail);

     

    I know there has to be a better, more compact way to write this bit of code.  Would I use an array?

     

    Code examples greatly appreciated as I am a php novice (but learnin more every day!).

     

    Anyone have suggestions for compacting this code?  FYI, there are more blocks of code in my file. I pasted 3 blocks of code above just so you can get the idea of how I wrote the code.

     

    Thanks in advance for any advice.

     

    dlc

  4. Hello everyone.  I have a script that is used to process a contact form.  When I receive the email from the script I see code in the email, like this:

    [code]

    From: DAVE@MYHOST.COM X-pstn-levels: (S:16.29645/99.90000 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 5 (2.0000:2.0000) s gt3 gt2 gt1 r p m c X-pstn-addresses: from forward (good recip) [561/25]

    [/code]

    The rest of the email is fine.

    Here's a bit of the code that generates the email:

    [code]

    // To send HTML mail, the Content-type header must be set

    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= "To: dave@myhost.com" . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

    // Additional headers
    $headers .= "From: $email" . "\r\n";

    if ($_POST['id'] == 'book') {
    $headers .= 'Cc: tom@myhost.com' . "\r\n";
    }

    // Mail it
    mail($to, $subject, $messagecontent, $headers);

    }

    [/code]

    Anyone have suggestions?
×
×
  • 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.