message templates

Ask about a PHP problem here.
Post Reply
hassansherif
Posts: 6
Joined: Tue Apr 17, 2012 10:53 am

message templates

Post by hassansherif »

when im creating a message i want to choose a template first. for example

when im on the page where i create and send the message i should have 3 radio buttons listing the available templates
and when i select one a click on submit the text area appears with the pre-set template in it

i created the bottons and i have the text area but i have no idea how to make it appear based on what i selected

any help?? :D
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: message templates

Post by jacek »

How do you want to store the templates ? there are a couple of ways you could do it.

You could just code them into the file
if($_POST['template'] == 1){
    // use template 1
}else if ($_POST['template'] == 2){
    // use template 2
}else{
    // use default template
}
or you could store them in an array
$templates[] = 'template 1';
$templates[] = 'template 2';

if (!empty($templates[$_POST['template']])){
    echo $templates[$_POST['template']];
}else{
    // use default template.
}
or a method with files. It really depends on the usage.
Image
Post Reply