The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
PHP Module loses user session info on form submit
Creating a form inside the php module.+
The form calls itself.+ Quick little snippet example Code:
global $vbulletin; if (!empty($_POST['sbutton'])){ Do some stuff, but we can't userid = 0 $vbulletin->userinfo['userid'] and even vB::getCurrentSession()->get('userid') returns 0 }else{ <form class='block' action='/forum/SituationReport' method='post' id='sitrep' name='sitrep'> <input type='submit' class='button' name='sbutton' id='_save' value='Submit'> } I tried adding the normal loading scripts but I get Couldn't read config file config.php Which is typical if its already loaded (Or at least in my experience) What else am I missing here. Script works outside of vbulletin as an external page. --------------- Added [DATE]1473374738[/DATE] at [TIME]1473374738[/TIME] --------------- @#%#@$% Figure out cause I was calling ./global.php I missed that. |
#2
|
||||
|
||||
For a simple form submission, I wouldn't bother with a PHP module. Most all the user data you need to work with is in the JS pageData array and whatever is not is easy enough to pull with an ajax call. Not sure what you're working on, but JS for forms is easy and can usually be as sophisticated as you need it to be.
|
#3
|
|||
|
|||
I wish my JS was decent. I barely scrape by using JS. I can do basic stuff like form validation, and manipulating variables. But other than that.
Was just a quick little Site Rep form that would post to the forum. |
#4
|
||||
|
||||
You don't have to read or load config.php file or any file for that matter. What is exactly do you want to accomplish?
You can get all of the public vbulletin options by doing this: Code:
$vboptions = vB5_Template_Options::instance()->getOptions(); $vboptions = $vboptions['options']; var_dump($vboptions); |
#5
|
|||
|
|||
Hey Glenn,
So I run the forums of a gaming community. In Milsim style we have a sit rep report. If someone does something good, or something bad there is a report someone can fill out and only certain people can see it in the forums. All the posting and stuff I have working (Thank you). So I was creating the form in a php module. I have a link on the submenu that calls it. However, I was so used to calling ./global.php from vb4 days I did it instinctively. What I found out is. When you do call ./global.php. It actually kills the user session. $vbulletin->userinfo['userid'] would = 0. I was losing my mind cause I was sure I fixed the posting code but it came up with no permissions. Well that was because it was having the userid, and session removed. All I had to do was remove the ./global.php include and everything worked. But I'm finding the more I post in here after I can't figure it out, its usually a few min later I figure it out on my own. |
#6
|
||||
|
||||
I have not having done any php coding in vb4 but after looking at it, there looks to be far more effort required for a vb4 mod vs vb5. Am I crazy? probably, but that just what ity looks like to me.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|