A snippet is basically a php script which is saved in the resources section, then you add the snippet call to the appropriate spot in your template or document where you want the script output to appear.
for this example we will use the snippet in a document.
1.) create a snippet named SampleLogin using the example form code below.
2.) create a new document or edit an existing one and add the snippet call to the document content area where the form would show like so:
[!SampleLogin!]
3.) in the action part of the snippet form code, since this example form posts back to itself, add the document ID (ex: 12)
<form id=’loginForm’ name=’loginForm’ method=’post’ action=’[~12~]’>
example form code:
<?php
/* Example form
*/
$output ="";
if(isset($_POST['submit']) && isset($_POST['password'])){
$output .="<div align='center'>Welcome ".$_POST['webusername'].", you are logged in...</div>";
}else{
$output .="<form id='loginForm' name='loginForm' method='post' action='[~12~]'>
<table width='300' border='0' align='center' cellpadding='2' cellspacing='0'>
<tr>
<td width='112'><b>Login</b></td>
<td width='188'><input name='webusername' type='text' class='textfield' id='webusername' /></td>
</tr>
<tr>
<td><b>Password</b></td>
<td><input name='password' type='password' class='textfield' id='password' /></td>
</tr>
<tr>
<td> </td>
<td><input type='submit' name='submit' value='Login' /></td>
</tr>
</table>";
}
return $output;
<?
This is a very basic example but should help you gain a bit of insight