Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Add a Form with Custom Page PHP Plugin

Well I'm trying to add a form to a Custom Page with PHP but I fail to understand how to add the form, I read this post: https://vanillaforums.org/discussion/comment/164208/#Comment_164208

This is my code:

<?php if (!defined('APPLICATION')) exit(); $Session = Gdn::Session(); $tsid = Gdn::UserMetaModel()->GetUserMeta($Session->UserID, 'Profile.tsid'); // Redirect guests to another custom page if (!$Session->IsValid()) { echo 'User not registred.'; }else { // Output of decho is only visible for admins echo $ts3id['Profile.tsid']; echo $this->Form->Open()); echo $this->Form->TextBox('MyField'); echo $this->Form->Button('Submit'); echo $this->Form->Close(); } ?>

I get error 500.

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    a) You've got echo $this->Form->Open()); with one closing bracket too much.
    b) When you've got a 500 error you should always check your servers error log file.
    c) You should omit the closing php tag ?> in Vanilla.
    d) Put echo $this->Form->Errors(); below Form->Open, so that you are able to ouput any error results.
    e) Not sure about this, but you've used Gdn::UserMetaModel()->GetUserMeta() as a static call although I think it should (must?) be called like that:

    $UserMetaModel = Gdn::UserMetaModel();
    $tsid = $UserMetaModel->GetUserMeta($Session->UserID, 'Profile.tsid');
    
  • edited January 2016

    Errors Corrected,
    But now only have a blank page

    echo $ts3id['Profile.TeamspeakID'];
    echo $this->Form->Open();
    echo $this->Form->Errors();
    echo $this->Form->TextBox('MyField');
    echo $this->Form->Button('Submit');
    echo $this->Form->Close();
    

  • hgtonighthgtonight ∞ · New Moderator
    var_dump($this);
    

    and post back

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

Sign In or Register to comment.