Page 1 of 1

message templates

Posted: Thu May 17, 2012 10:47 am
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

Re: message templates

Posted: Thu May 17, 2012 11:19 pm
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.