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.

Custom pages or vanilla CMS

jhardinjhardin New
edited September 2012 in Vanilla 2.0 - 2.8

Hello,

I could really use some help with this. I am trying to create a form for a registration for an event. I am hopeing that after I get this one form done I can then work on making it a plugin that would allow people to make custom forms in the future for various reasons.

The code is posted in the next comment.

I also need to find a way to deny access depending on roles.

I really don't know what I'm doing. I'm reading all kinds of things but not really finding the answers that I need and that might be because I don't know the right questions.

I am using an embedded version of the forum.

Thank you for your time.

Sincerely,

Comments

  •  <?php if (!defined('APPLICATION')) exit(); 
    
    
    
                 $Session = Gdn::Session();
                 if ($Session->IsValid()) {
                 $userid = $Session->UserID;
                $Name = $Session->User->Name; }
                echo $Name;
    
                new Database();         
                $Database->Select('Email');
                $Database->From('GDN_User');
                $Database->Where('Name =',$Name);
                $DataSet = $Database->Get();
                echo $Dataset;
    
    
    
                $con = mysql_connect("localhost","######","######");
                        if (!$con)
                            {
                            die('Could not connect: ' . mysql_error());
                            }
                mysql_select_db("######", $con) or die(mysql_error());
                $sql="INSERT INTO KhanKon2012 
                (email, username, GameSession1, GameSession2, GameSession3, GameSession4)
                VALUES ('$_POST[email]','$_POST[Name]','$_POST[GameSession1]','$_POST[GameSession2]','$_POST[GameSession3]','$_POST[GameSession4]')";
    
            if (!mysql_query($sql,$con))
                    {
                    die('Error: ' . mysql_error());
                    }
            echo "1 record added";
    
     mysql_close($con);
    
     ?>
    
  • jhardinjhardin New
    edited September 2012

    So this is what I have now but the submit button doesn't seem to do anything

    <?php if (!defined('APPLICATION')) exit(); 
    
    
        // only execute if postback
    
    
                $Session = Gdn::Session();
                if ($Session->IsValid()) {
                $userid = $Session->UserID;
                $Name = $Session->User->Name; }
    
                $con = mysql_connect("","","");
    
                mysql_select_db("ourplayb_vnl1", $con) or die(mysql_error());
    
                $result = mysql_query("SELECT Email FROM GDN_User 
                WHERE Name='$Name'");
    
                if (!$result) {
                    $message  = 'Invalid query: ' . mysql_error() . "\n";
                    $message .= 'Whole query: ' . $query;
                    die($message);
                }
    
                    $row = mysql_fetch_assoc($result);
                    var_dump($row); // see what type of variable mysql_fetch_array() gave you
                    $Email2 = $row['Email'];  // ...and use that knowledge here
    
    if($_SERVER['REQUEST_METHOD'] == 'POST')
    {
    
    
                $sql="INSERT INTO KhanKon2012 (email, username, GameSession1, GameSession2, GameSession3, GameSession4)
                VALUES ('$Email2','$Name','$_POST[GameSession1]','$_POST[GameSession2]','$_POST[GameSession3]','$_POST[GameSession4]')";
    
                if (!mysql_query($sql,$con))
                    {
                    die('Error: ' . mysql_error());
                    }
            echo "1 record added";
    
    mysql_close($con);
    }
    
    ?>
    
    
    <p>Pleas pick which events at the CON you would like to attend.</p>
    
    <h1>Saturday</h2>
    
    <form method="post" action="<?php echo $PHP_SELF;?>">
    <select name="GameSession1">
        <option value="battlestar">Battlestar Galactica</option>
        <option value="vampire">Vampire Red Dawn (GM: Francis)</option>
        <option value="something">Something else</option>
    </select>
    
    
    <select name="GameSession2">
        <option value="battlestar">Battlestar Galactica</option>
        <option value="vampire">Vampire Red Dawn (GM: Francis)</option>
        <option value="something">Something else</option>
    </select>
    
    
    
    <select name="GameSession3">
        <option value="battlestar">Battlestar Galactica</option>
        <option value="vampire">Vampire Red Dawn (GM: Francis)</option>
        <option value="something">Something else</option>
    </select>
    </form>
    
    
    
    <h1>Sunday</h2>
    <select name="GameSession4">
        <option value="battlestar">Battlestar Galactica</option>
        <option value="vampire">Vampire Red Dawn (GM: Francis)</option>
        <option value="something">Something else</option>
    </select>
    <input type="submit" value="submit" name="submit_button" />
    
    </form>
    

    Does anybody have any advice as to what I am doing heinously wrong?

  • I suggest you create a plugin instead of creating a reg page using CustomPages. Check out the AboutMe plugin. it's one of the most basic and simple plugin i can think of that uses Form submission. => http://vanillaforums.org/addon/aboutme-plugin

  • With a plugin can I have it on a seperate page?

  • peregrineperegrine MVP
    edited September 2012

    check out the members plugins. They produce separate pages and are plugins. That with Aolee's suggestion should provide you a good start. Don't be afraid to start over from scratch, it might be easier. Also read the documentation on models, views, controllers, and modules. Also look at plugins by the the creators of vanilla and x00 to name a few.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks, I've been looking at aboutme and I'm starting to understand a bit more what I was doing wrong. I'll also check out the other ones you mentioned. I think when I am done, I will write up a tutorial to help other noobs who are having similar problems as me. At the vary least I will post something here for other people to see when I get 'something' working and hopefully somebody on the forum can then say why what I'm doing is wrong for everyone's education.

    Vanilla is a great piece of software and I hope more people end up using it.

  • peregrineperegrine MVP
    edited September 2012

    I clicked awesome, because you look like you want to give back to the community after you learn some things, and the buttons awesome, insightful are used to show your appreciation for help as well as intentions implied by the commenter.

    this might also provide some insights on plugins, applications, etc.

    http://vanillaforums.org/discussion/comment/165696/#Comment_165696

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks for the vote of awesome. Hopefully I can get this done. I am making some progress, thank you for pointing in the right direction.

  • jhardinjhardin New
    edited September 2012

    So, I followed through with just using the custom pages and it seems to be working now. However, after reading what you guys had to say it does seem making it as a plugin would make many times over more sense.

    However, this is what I have so far.

Sign In or Register to comment.