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

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2009, 05:15 PM
TerryMason TerryMason is offline
 
Join Date: Oct 2005
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Passing a form variable to a template

I'm a rookie with php, and having a hard time getting a variable passed to my template.

I have template1, with this code in it:

Code:
<form action="template2_file.php" method="post"> enter your data here: <input name="variable" type="text"/> <input type="submit" Label="submit"/></form>

and I'd expect the variable to be passed in the title, and be avaliable as the variable $variable. I'd like to display an image like

path/to/image/ $variable .jpg on the next page.

Is this possible? I've tried using plugins, but couldn't get that to work.
Reply With Quote
  #2  
Old 03-08-2009, 06:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The post method does not pass the text in the title/url. The get method does that. I would not pass text though using get. The variable should be available in the form as $_POST['variable'] (I'm not sure if it will like the name 'variable'.) You should use the vb cleaner on it when it gets there - https://vborg.vbsupport.ru/showthread.php?t=119372
Reply With Quote
  #3  
Old 03-08-2009, 11:57 PM
TerryMason TerryMason is offline
 
Join Date: Oct 2005
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne,
Thank you very much for helping, but I'm afraid that's over my head. I'm not actually using the variable name variable, but instead it's "player". I' tried this:

<img src="http://www.xxxxxxxx.com/sig/test/1/$_POST['player'].jpg">

but I get this error from my template when I go to save

Code:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/xxxxxx/public_html/includes/adminfunctions_template.php(3938) : eval()'d code on line 19

Is there anywhere I can go to read about passing variables, or just programming with php inside of VB? Everything I read wants me to use plugins, but I don't think that I can do that with what I'm attempting.

Basically, I just want page1 to have a text input field that the user types into which will forward them to page2 take will that input, and put it in the url of an image file (i.e. www.xxxxxx.com/image/USERINPUT.jpg
Reply With Quote
  #4  
Old 03-09-2009, 03:36 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The variable gets passed to the page "template2_file.php"according to your form. That is where it should be available for use as $_POST['player'].

If you are not familiar with forms, then you really should read a tutorial or two about how they work.
Reply With Quote
  #5  
Old 03-09-2009, 11:58 AM
TerryMason TerryMason is offline
 
Join Date: Oct 2005
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know I'm being dense, and I really want to thank you for helping, but I'm still lost.

template2_file.php is another vb formatted template file, so all the coding for that page is in a vb template.

I agree that I should read up on forms, but I need to know how to include forms inside of a vb template (not just a form in general), and there doesn't seem to be a tutorial on that.
Reply With Quote
  #6  
Old 03-09-2009, 12:00 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try $_POST[player] in your form
Reply With Quote
  #7  
Old 03-09-2009, 12:41 PM
TerryMason TerryMason is offline
 
Join Date: Oct 2005
Posts: 57
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oops, didn't read carefully enough

--------------- Added [DATE]1236606266[/DATE] at [TIME]1236606266[/TIME] ---------------

THANK YOU!!!

thanks both of you guys.

Check out the fruits of my labors:
http://www.fpstactics.com/gaming_signatures.php

just put in my username of terrynator to see it work.
Reply With Quote
  #8  
Old 03-09-2009, 02:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's pretty cool!
Reply With Quote
Reply


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 07:36 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04716 seconds
  • Memory Usage 2,226KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (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_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
  • 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