PHP in Page Node

Zovator

Member
Hello,
I have a simple PHP file with a form that connects to a MySQL database and sends application information to the database. I'm not sure how to include this PHP in a page node, does anyone know how I would do this? If you have an alternative way for doing this I would like to hear it as well.
~ Thanks.
 
The correct way would be to use xen:link syntax:

Code:
action="{xen:link 'pages', $page}"

That will parse to the URL of the page, so the form will submit to itself. Then you can check for the form submission in your callback.
 
The correct way would be to use xen:link syntax:

Code:
action="{xen:link 'pages', $page}"

That will parse to the URL of the page, so the form will submit to itself. Then you can check for the form submission in your callback.
Ok, thanks. I'm not sure why, but I keep getting:
Security error occurred. Please press back, refresh the page, and try again.
when I submit with the form.
 
Include this hidden field in your form:

Code:
<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />

That will satisfy the CSRF check which should fix that error.
 
You should only access that variable on a form submission.

Code:
$request = $controller->getRequest();

if ($request->isPost())
{
	// THEN PROCESS FORM SUBMISSION
}

...assuming your HTML form has method="POST"
 
You should only access that variable on a form submission.

Code:
$request = $controller->getRequest();
 
if ($request->isPost())
{
// THEN PROCESS FORM SUBMISSION
}

...assuming your HTML form has method="POST"
Sorry to bother you again, I added all the forms and now I'm getting:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
What does this mean?
 
That is a problem with a db call. I need to see the code that generates that error.

Code:
<?php
 
class Callback_PageNode
{
    public static function candidacyapply(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    {
        $mydb = new Zend_Db_Adapter_Pdo_Mysql(array(
            'host'    => 'localhost',
            'username' => 'members',
            'password' => '---------',
            'dbname'  => 'members'
        ));
       
        $request = $controller->getRequest();
 
if ($request->isPost())
{
            $mydb->insert(
            'pending',
            array('Username' => $_REQUEST['formusername'], 'Timezone' => $_REQUEST['formtimezone'], 'Given Name' => $_REQUEST['formname'], 'Last Name Initial(s)' => $_REQUEST['forminitials'], 'Ship 1' => $_REQUEST['formship1'], 'Ship 2' => $_REQUEST['formship2'], 'Ship 3' => $_REQUEST['formship3'], 'Ship 4' => $_REQUEST['formship4'], 'Ship 5' => $_REQUEST['formship5'], 'Ship 6' => $_REQUEST['formship6'], 'Ship 7' => $_REQUEST['formship7'], 'Ship 8' => $_REQUEST['formship8'], 'Ship 9' => $_REQUEST['formship9'], 'Ship 10' => $_REQUEST['formship10'], 'Ship 11' => $_REQUEST['formship11'], 'Ship 12' => $_REQUEST['formship12'], 'Ship 13' => $_REQUEST['formship13'], 'Ship 14' => $_REQUEST['formship14'], 'Ship 15' => $_REQUEST['formship14'], 'Ship 1 Given Name' => $_REQUEST['formshipname1'], 'Ship 2 Given Name' => $_REQUEST['formshipname2'], 'Ship 3 Given Name' => $_REQUEST['formshipname3'], 'Ship 4 Given Name' => $_REQUEST['formshipname4'], 'Ship 5 Given Name' => $_REQUEST['formshipname5'], 'Ship 6 Given Name' => $_REQUEST['formshipname6'], 'Ship 7 Given Name' => $_REQUEST['formshipname7'], 'Ship 8 Given Name' => $_REQUEST['formshipname8'], 'Ship 9 Given Name' => $_REQUEST['formshipname9'], 'Ship 10 Given Name' => $_REQUEST['formshipname10'], 'Ship 11 Given Name' => $_REQUEST['formshipname11'], 'Ship 12 Given Name' => $_REQUEST['formshipname12'], 'Ship 13 Given Name' => $_REQUEST['formshipname13'], 'Ship 14 Given Name' => $_REQUEST['formshipname14'], 'Ship 15 Given Name' => $_REQUEST['formshipname15'], 'Rank' => $_REQUEST['rank'], 'Why did you choose the SUN?' => $_REQUEST['formwhydidyouchoose'], 'What can you contribute?' => $_REQUEST['formwhatcanyougive'], 'How did you find out about SUN?' => $_REQUEST['formhowdidyoufind'], 'Do you have any specialties?' => $_REQUEST['formspecialties'], 'How do you see yourself playing SC?' => $_REQUEST['formplaying'], 'Extra comments/queries' => $_REQUEST['formcomments'])
            );
           
}
    }
}
 
The insert specifies the column names are their values. But you appear to be using invalid column names (containing spaces). Look at the table in the database to see the column names.
 
Hmm. I assumed column names weren't allowed to have spaces. I guess I never tried it in 10 years of working with MySQL databases. =\

The ? character is normally the token. Some of your column names have a ? in them. Is that correct? That might be causing the error. Maybe the token can be escaped. I don't know if this is possible or necessary. I would just remove the ? character from your column names. That may fix the error.
 
Hmm. I assumed column names weren't allowed to have spaces. I guess I never tried it in 10 years of working with MySQL databases. =\

The ? character is normally the token. Some of your column names have a ? in them. Is that correct? That might be causing the error. Maybe the token can be escaped. I don't know if this is possible or necessary. I would just remove the ? character from your column names. That may fix the error.
Ah! That did it, thank you very much!
 
Top Bottom