vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Passing a form variable to a template (https://vborg.vbsupport.ru/showthread.php?t=207717)

TerryMason 03-08-2009 05:15 PM

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.

Lynne 03-08-2009 06:07 PM

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

TerryMason 03-08-2009 11:57 PM

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

Lynne 03-09-2009 03:36 AM

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.

TerryMason 03-09-2009 11:58 AM

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.

ragtek 03-09-2009 12:00 PM

Try $_POST[player] in your form

TerryMason 03-09-2009 12:41 PM

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.

Lynne 03-09-2009 02:33 PM

That's pretty cool!


All times are GMT. The time now is 02:41 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.01066 seconds
  • Memory Usage 1,726KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete