The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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. |
#2
|
||||
|
||||
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
|
#3
|
|||
|
|||
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 |
#4
|
||||
|
||||
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. |
#5
|
|||
|
|||
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. |
#6
|
|||
|
|||
Try $_POST[player] in your form
|
#7
|
|||
|
|||
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. |
#8
|
||||
|
||||
That's pretty cool!
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|