Page 1 of 1

PHP tags not working as they should

Posted: Wed Feb 15, 2006 3:50 pm
by Dopple
My Code is below. I have turnerd on php tags in config.php but this just displays the text between the first {php} tags. I'm assuming it's taking what's between the { characters and treating whats between tehm as a tag. How should I sort this? I tried to put the stuff in a user defined tag but kept saying "invalide code entered".

Contact form
Send the Bassmonsta a message


{php}if ($_SERVER['REQUEST_METHOD'] != 'POST'){$me = $_SERVER['PHP_SELF'];{/php}

 
   
      Name:
   
   
      Email:
   
   
      Query/Question:
        Enter your query here...
   
   
     
   
 
   
 

{php}
} else {
      error_reporting(0);
      $recipient = 'graham@namik.co.uk';
      $name = stripslashes($_POST['name']);
      $email = stripslashes($_POST['email']);
      $msg = "Message from: $email\n\n".stripslashes($_POST['query']);
      if (mail($recipient, 'MEssage from bassmonsta.co.uk', $msg))
        echo nl2br("Message Sent:
        To: $recipient
        Subject: Email from bassmonsta.co.uk
        Message:
        $msg");
      else
        echo "Message failed to send";
}
{/php}


Re: PHP tags not working as they should

Posted: Wed Feb 15, 2006 4:12 pm
by Ted
If you use a user defined tag (which you should), pretend that it already did the at the end.

So, start your function off right away with ?>etc  and end with <?php

From a programming standpoint, a user defined tag is a php function.  So, pretend that right before your code is the function somefunctionname() { part.

Re: PHP tags not working as they should

Posted: Thu Feb 16, 2006 9:36 am
by Dopple
As I need the code to start at the begining of the form, and end efter it I'm thinking I'll need 3 different user defined tags. I've changed the code to show where with "*TAG HERE*"
If I want the following code in a use defined tag,
if ($_SERVER['REQUEST_METHOD'] != 'POST'){
$me = $_SERVER['PHP_SELF'];

What would I put in the actual tag editor? No matter what I've tried it tells me it's invalid. Apart from when I removed all the code from and including the { and placed a ; at the end.


*TAG HERE*

 
   
      Name:
   
   
      Email:
   
   
      Query/Question:
        Enter your query here...
   
   
     
   
 
   
 


*TAG HERE*

Re: PHP tags not working as they should

Posted: Thu Feb 16, 2006 9:40 am
by Dopple
Never mind. I understand what you were saying now. I chucked all of the code into the tag apart from the first opening and last closing php tag.
Thanks