Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-02-2015, 07:16 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Form action help

Code:
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>
I require that on the form method, although I'm aware that vbulletin requires the variable name for the action method.

E.g:

Code:
<form name="upgrade" method="POST" action="{vb:raw _SERVER.PHP_SELF}">
So how can I have that in the variable format?
Reply With Quote
  #2  
Old 07-02-2015, 07:21 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Does that not work? Or is it the htmlspecialchars() that you're wondering about? I think if you use vb:var instead of vb:raw it does htmlspecialchars() on the value.
Reply With Quote
  #3  
Old 07-02-2015, 08:11 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's this page you see:

http://spawnscape614.co.uk/forums/reportuser.php?

And I'm trying to validate the first input for a test. And when clicking the send report button it simply reloads...
Appropriate html:
Code:
<form class="vbform block" action="{vb:raw _SERVER.PHP_SELF}">
<label for="username">Enter offender's name: </label>
				<input type="text" class="primary textbox" id="name" name="username" tabindex="1" /></input><span class="error"> * <?php echo $usernameErr;?></span>
<input type="submit" class="button" value="Send Report" tabindex="1"  />
</form>
Appropriate php:

PHP Code:
$usernameErr "";
$username "";
if(isset(
$_POST['submit'])) {
   if (empty(
$_POST["name"])) {
     
$nameErr "Name is required";
   } else {
     
$name test_input($_POST["name"]);
   }
   
}

   function 
test_input($data) {
   
$data trim($data);
   
$data stripslashes($data);
   
$data htmlspecialchars($data);
   return 
$data;

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

Idk why it just reloads. And I tried the var instead of the raw and it didn't work.
Reply With Quote
  #4  
Old 07-07-2015, 01:17 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Could anyone up?
Reply With Quote
  #5  
Old 07-07-2015, 03:08 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I missed your response.

OK, I had to do a little test to figure these things out, but first you need method="POST" in your form tag. Second, the indexes into $_POST are the name attributes of the input fields, so if you want to check for submit, you want to add name="submit" to that tag like:
HTML Code:
<input name="submit" type="submit" class="button" // etc

If you don't have a name attribute, the input will not go into the $_POST array at all.

You also want to use 'username' when checking the name, since that's the value of the name attribute.
Reply With Quote
  #6  
Old 07-08-2015, 05:22 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm it's still not working. Do you have skype? I'll pay for your assistance btw.
Reply With Quote
  #7  
Old 07-08-2015, 05:28 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't really do that right now, but here's the test program I used. I just put it in a file called test.php and pointed my browser there. It's not a vbulltin file at all, just a simple php file.

PHP Code:
<form method="POST" class="vbform block" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label for="username">Enter offender's name: </label>
                <input type="text" class="primary textbox" id="name" name="username" tabindex="1" /></input><span class="error"> * </span>
<input name="submit" type="submit" class="button" value="Send Report" tabindex="1"  />

</form>
<br/><br/>
<?php

if (array($_POST) && count($_POST))
{
   
var_dump($_POST);
}   
else
   echo 
'$_POST empty';
?>
Reply With Quote
  #8  
Old 07-09-2015, 02:28 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, what I put worked on a page without vbulletin; although it doesn't work inside a vbulletin page.
Reply With Quote
  #9  
Old 07-09-2015, 02:32 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh, OK. Did you try this for the code:
PHP Code:
$usernameErr ""
$username ""
if(isset(
$_POST['submit'])) { 
   if (empty(
$_POST["username"])) { 
     
$nameErr "Name is required"
   } else { 
     
$name test_input($_POST["username"]); 
   } 
    


   function 
test_input($data) { 
   
$data trim($data); 
   
$data stripslashes($data); 
   
$data htmlspecialchars($data); 
   return 
$data


and you said you added name="submit" to the submit button, right?

It's hard to tell if that's everything you need without seeing the big picture. Where are you putting that code, if that a plugin, or is reportuser.php a custom script? (I guess it's not a vbuletin file so that's probably it).
Reply With Quote
  #10  
Old 07-09-2015, 02:53 PM
Duckface Duckface is offline
 
Join Date: Apr 2015
Posts: 98
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's a basic custom file.

Here is the page:

http://spawnscape614.co.uk/forums/reportuser.php

It's not a plugin either. Would you like the entire template?
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 08:31 AM.


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.06312 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
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
  • (3)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete