vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Echoing A Variable? (https://vborg.vbsupport.ru/showthread.php?t=131751)

paul41598 11-16-2006 09:02 PM

Echoing A Variable?
 
Im doing something very basic and Im stumped for whatever reason.

Basically in the showthread template I have a text line called

<input type="text" name="testme" value="$testme" size="12">

When I click the perform action button it should echo whats in the variable "a.k.a" a string.

In postings.php Im trying to echo $testme;

No luck. Make sense?

Antivirus 11-16-2006 09:20 PM

i think you need to place your var within "" like

Code:

echo "$testme";

paul41598 11-16-2006 10:27 PM

naw that didnt work either. Hmm...


In postings.php I have


PHP Code:

if ($_POST['do'] == 'test')
{
echo 
"$testme";


in the showthread template I have:

PHP Code:

<div><label for="ao_cct"><input type="radio" name="do" id="ao_cct" value="outputit" />OutPut It!</label></div>

<
input type="text" name="testme" value="$testmesize="12"

That code is right beneath all the other admin functions like Split Thread, Move Thread, etc. So when you hit Perform action, it should post that variable back.


I'm not even sure if Im doing this right...



Ok I did a
PHP Code:

if (isset($testme)) {    
echo 
"$testme";
}
else {
echo 
"crap";


and I saw the word crap, which means the variable isnt being passed or SET

Guest190829 11-17-2006 06:42 PM

Where are you setting $testme?

paul41598 11-17-2006 06:48 PM

1 Attachment(s)
in a text box, value="$testme"

and the text box is actually under one of the radio buttons in the threadadmin manage. see below

Guest190829 11-17-2006 06:52 PM

Quote:

Originally Posted by paul41598 (Post 1119504)
in a text box, value="$testme"

and the text box is actually under one of the radio buttons in the threadadmin manage. see below

The variable will be in the $_POST array, but you would use vBulletin's built in sanitizing array:

PHP Code:

$vbulletin->input->clean_gpc('p''testme'TYPE_NOHTML)); 

The new variable would be:

PHP Code:

$vbulletin->GPC['testme'


paul41598 11-17-2006 07:03 PM

wow that worked! Thankyou so much, I'm sure I'll have more questions later to be asked now that I got past this part. Thanks again Danny

what about a checkbox variable sir? How do I pass that on?

Guest190829 11-17-2006 07:39 PM

Quote:

Originally Posted by paul41598 (Post 1119521)
wow that worked! Thankyou so much, I'm sure I'll have more questions later to be asked now that I got past this part. Thanks again Danny

what about a checkbox variable sir? How do I pass that on?

Checkboxes are held in arrays so it would be something like:

HTML Code:

<input type="checkbox" name="options[]" value="x">

<input type="checkbox" name="options[]" value="y">

<input type="checkbox" name="options[]" value="y">

The php code would be:

PHP Code:

$vbulletin->input->clean_gpc('p''options'TYPE_ARRAY)); 

And $vbulletin->GPC['options'] would be an array of all the values that were checked.

paul41598 11-17-2006 08:12 PM

Thanks Danny, seems to be working so far!

Guest190829 11-17-2006 08:45 PM

I'm glad everything is working. Get into the habit of sanitizing all of your variables, as it is a security risk if you don't.

If you need more information on it, there is documentation inside the file at

includes/class_core.php

:)


All times are GMT. The time now is 08:40 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.01288 seconds
  • Memory Usage 1,747KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_html_printable
  • (6)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete