Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-21-2012, 01:26 PM
Preech Preech is offline
 
Join Date: Aug 2002
Location: Fort Campbell
Posts: 325
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Forms and Insert to the DB

So I am still working on my mod, where the admin can create, lets say a new artist.
I can get the page to show up, everything looks good, when I go to submit the form, nothing happens.

Here is the Php Code
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''vbmusic_create_artist');
define('CSRF_PROTECTION'true);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('vbmusic_create_artist',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits construct_navbits(array('' => 'Create Artist'));
$navbar render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Create Artist';

if (
$_POST['do'] == 'createartist')
{
if (
$createartist=='send') {

        
$name $vbulletin->input->clean_gpc('p''name'TYPE_STR);
    
$dbirth $vbulletin->input->clean_gpc('p''dbirth'TYPE_UINT);
    
$country $vbulletin->input->clean_gpc('p''country'TYPE_STR);
    
$homepage $vbulletin->input->clean_gpc('p''homepage'TYPE_STR);
    
    if (
$name!='') {
    
    
$vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "artist
        (arname, dbirth, lbirth, homepage)
        VALUES ('"
.$name."','".$dbirth."', '".$country."') ");    
        
    
$id $vbulletin->db->insert_id();
    
    
$vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "artdescr
        (arid, ardescr)
        VALUES (
            '"
.$vbulletin->db->escape_string($id)."',
            '"
.$vbulletin->db->escape_string('')."' 
        "
);
    
    
    
    
//$vbulletin->url = "forms.php?do=editform&fid=$id";    
    
eval(print_standard_redirect('redirect_insertform'));



      
//if ($save) $mess="Your data was successfully saved.";
     // else $mess="There was an SQL error!";
      
}
   
//else $mess="Please provide a name!";

}
}
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######

$templater vB_Template::create('vbmusic_create_artist');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('dbirth'$dbirth);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>
Here is the template
PHP Code:
{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <
head>
    <
title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {
vb:raw headinclude}
    {
vb:raw headinclude_bottom}
  </
head>
  <
body>
    
    {
vb:raw header}
    
    {
vb:raw navbar}


<
br />
    
<
div class="colmask leftmenu">
    <
div class="colleft">
        <
div class="col1">
            <!-- 
Column 1 start -->



<
div class="audio_head">Create Artist</div>
<
div class="audio_body">


    
<!--<
form action="./vbmusic_create_artist.php" method="post">-->
<
form class="vbform block" action="vbmusic_create_artist.php?do=createartist" method="post" name="vbform" onsubmit="return .prepare_submit(0, 0)">
<
input type="hidden" name="do" value="insertform" />
<
input type="hidden" name="s" value="{vb:raw session.sessionhash}" />
<
input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />

<
table align="center" cellspacing="0" cellpadding="0" width="100%" class="tablec"
 <
tr
  <
td valign="top" align="center">
   <
table align="center" cellspacing="10" cellpadding="0" width="100%">
<
input type="hidden" name="securitytoken" value="{vb:raw bbuserinfo.securitytoken}" />
    <
tr>
     <
td style="width:35%;" align="right">Name :</td>
     <
td style="width:65%;" align="left">
 <
input type="text" name="name" size="50" value="">
   
     </
td>
    </
tr>
    <
tr>
     <
td align="right" class="data1">Date of birth :</td>
     <
td align="left">
      <
input type="text" name="{vb:raw dbirth}" size="50" value="">
     </
td>
    </
tr>
    <
tr>
     <
td align="right" >Land of birth :</td>
     <
td align="left">{vb:raw lbirth}</td>
    </
tr>
    <
tr>
     <
td align="right" >Homepage :</td>
     <
td align="left">
      <
input type="text" name="{vb:raw homepage}" size="50" value="">
     </
td>
    </
tr>
   </
table>
  </
td>
 </
tr>
</
table>
<
table align="center" cellspacing="0" cellpadding="0" width="100%" 
 <
tr
  <
td valign="top" align="center">
   <
table align="center" cellspacing="10" cellpadding="0" width="100%">
    <
tr>
     <
td style="width:35%;" align="right" class="data1">Upload image from URL :</td>
     <
td style="width:65%;" align="left">
      <
input type="hidden" name="MAX_FILE_SIZE" value="".($csiz*1024)."\" />
      <input class="
text" type="text" name="covurl" size="55" >
     </td>
    </tr>
    <tr>
     <td align="
right">Upload image from your PC :</td>
     <td align="
left">
      <input type="
hidden" name="MAX_FILE_SIZE" value="".($csiz*1024)."" />
      <input type="
file" name="covfil" size="50" accept="image/jpeg">
     </td>
    </tr>
   </table>
  </td>
 </tr>
</table>
<table align="
center" cellspacing="20" cellpadding="0" width="100%" class="tablec"> 
 <tr> 
  <td valign="
middle" align="center"><input class="button" type="submit" value="Submit!"></td>
 </tr>
</table>
</form>

    </div>


            <!-- Column 1 end -->
        </div>
        <div class="
col2">
            <!-- Column 2 start -->
<div class="
audio_head">Menu</div>
<div class="
audio_body">
        <table align="
center" cellspacing="0" cellpadding="0" width="100%" > 
 <tr> 
  <td valign="
top" align="center">
   <table align="
center" cellspacing="5" cellpadding="0" width="100%"> 
    <tr> 
     <td align="
left"><a href="vbmusic.php" title="" alt="">- Music Home</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"browse.php?typ=artist\" title=\"\" alt=\"\">- Browse Artist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"browse.php?typ=album\" title=\"\" alt=\"\">- Browse Albums</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"browse.php?typ=genre\" title=\"\" alt=\"\">- Browse Genre</a></td>
    </tr>

 <tr> 
     <td align=\"left\"><a href=\"import.php\" title=\"\" alt=\"\">- Import Albums</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"config.php\" title=\"\" alt=\"\">- Config Settings</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"usr_list.php\" title=\"\" alt=\"\">- Userlist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"showlog.php\" title=\"\" alt=\"\">- Show Log</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"stats.php\" title=\"\" alt=\"\">- Statistics</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"create_artist.php\" title=\"\" alt=\"\">- Create artist</a></td>
    </tr>
    <tr> 
     <td align=\"left\"><a href=\"del_artist.php\" title=\"\" alt=\"\">- Delete artist</a></td>
    </tr>


</table>
  </td>
 </tr>
</table>
        </div>
    

            
            <!-- Column 2 end -->
        </div>
    </div>
</div>
    {vb:raw footer}
  </body>
</html> 
Also, I would I go about getting the select a option info from the database.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:53 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03710 seconds
  • Memory Usage 2,701KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_code
  • (4)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_threadedmode.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete