Ok, I have been trying to implement your suggestions from a previous post, but it is not working. So how do I implement this in Modx??
Here is my setup:
I have my HTML form contained in a snippet called html_form, and I have this formed contained in my page like this: {{html_form}}. Now I have in the snippet section of modx a snippet named form_proc which connects to the database and all of that. So inside the html_form, under the action= what kind of syntax do I use to reference the form_proc in the snippets section of modx?
Thanks in advance!
PS. I have tried [~form_proc~], [[form_proc]], and [form_proc] - none of which worked.
You can combine all that into one snippet may be the easiest route, try something like this:
Take the format below and create your own snippet, name it whatever and call it on a document like so:
[!ExampleForm!]
<?php
/* Example form snippet
-> if the submit button is pressed, the form is processed and result is shown,
otherwise show the form
*/
$output ="";
if(isset($_POST['submit'])){
// add your form process code here in the $output variable
$output .="<div align='center'>Welcome ".$_POST['webusername'].", you are logged in...</div>";
}else{
// add your form code here in the $output variable
$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;
?>
In this example snippet the action=’[~12~]’ spot, the 12 is the ID of the document itself which contains this snippet code, since in this example the form and processor are on the same page.
Yeah, actually html_form is a chunk, sorry for that misprint!