Inserting PhP scripts in a template
Inserting PhP scripts in a template
I am trying to create a login system in my cms template, but it the PHP scripts don't seem to work when I put them in a template. Am I doing something wrong?
Re: Inserting PhP scripts in a template
For example:
I want the login form to show up when your not logged in and the action should sent the information to the page himself. I haven the following script, it works on a normal site, but not in a cmsms template...:
I want the login form to show up when your not logged in and the action should sent the information to the page himself. I haven the following script, it works on a normal site, but not in a cmsms template...:
Code: Select all
<?php if(!isset($_SESSION["login"])){ ?>
<table width="140" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="logintabel" align="center">
<form name="loginform" method="post" action="<?php echo($_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']); ?>">
Username:<br>
<input name="loginusername" type="text"><br>
Password:<br>
<input name="loginpassword" type="password"><br>
<input name="loginsubmit" type="submit" value="Login">
</form>
<h3><a href="phpbb/index.php">Registreren!</a></h3></td>
</tr>
</table>
<?php } ?>
Re: Inserting PhP scripts in a template
Create a User defined tag, place all your php code there, and insert into the template {your_tag_name}
Re: Inserting PhP scripts in a template
So I should create a user defined tag for every little piece of PHP?
Isn't there an other way? {php}{/php} or {literal}{/literal}
Isn't there an other way? {php}{/php} or {literal}{/literal}
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Inserting PhP scripts in a template
Yes, you can use {literal}{/literal} and for complex, multi-part php stuff, that may be the better way.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Inserting PhP scripts in a template
For php code, you can use {php}{/php}. However, in order for it to work, you need to set the allow_php_tags (I think?!? -- something close to that) value to true in config.php.
Re: Inserting PhP scripts in a template
OK, that's the solution:
For PHP to work in a template edit the config.php
$config['use_smarty_php_tags'] = true; (false = standard)
and then use {php} and {/php} to replace the tags
Thanx for the ideas.....
For PHP to work in a template edit the config.php
$config['use_smarty_php_tags'] = true; (false = standard)
and then use {php} and {/php} to replace the tags
Thanx for the ideas.....
Re: Inserting PhP scripts in a template
Hi all ! 
I would like to know, if we want to insert an enter in a sql database, we will use naturally php without any problems ?
Tanks a lot.

I would like to know, if we want to insert an enter in a sql database, we will use naturally php without any problems ?

Tanks a lot.

Re: Inserting PhP scripts in a template
Cool, thanks for that. I was wondering and... my question is answered!Anduril wrote: $config['use_smarty_php_tags'] = true; (false = standard)
and then use {php} and {/php} to replace the tags