PDA

View Full Version : Passing a form variable to a template


TerryMason
03-08-2009, 05:15 PM
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:


<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

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 1236606266 at 1236606266 ---------------

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!