View Full Version : Few vbcoding queries
veenuisthebest
09-03-2008, 07:25 AM
1. vB uses this code to redirect to any location (in our case page.php), how do I redirect to previous page that user accessed?
$vbulletin->url = "page.php" . $vbulletin->session->vars['sessionurl'];
if (isset($_SERVER['QUERY_STRING'])) {
eval(print_standard_redirect('redirect_linkdir', true, true));}I then found this:-
require_once(DIR . '/includes/functions_login.php');
$vbulletin->url = fetch_replaced_session_url($vbulletin->url);But it isn't working for me. How do I go a couple of pages back from history ?
2. How do I create online locations for my sub-pages like for do=this and do=that
3. After reading Send PMs (automatically) (https://vborg.vbsupport.ru/showthread.php?t=82786), it was easy to send PM's. Just have a few queries, what does $pmdm->set_info('is_automated', true); AND cache_permissions($fromuser, false); does ? coz I can't see any difference with/without them.
4. How do we use vbmail function in our page? I think there's something wrong in my code as I am getting very late mails OR not getting them at all. The other default mailing functions are working perfect i.e. I receive mails instantly when using contact us or any other email function but only not through my custom page.
$emailto = "email@email.com";
$subject = "my email subject";
$message = "my message body";
vbmail($emailto, $subject, $message);
veenuisthebest
09-17-2008, 07:23 PM
i am still waiting... !!!!!
The main problem i am facing is with my first question. What the problem is that I have to create similar two sub-pages just because I want both of them to redirect at different locations on submitting the form.
For ex. with the below code in page.php?do=this, it would redirect to page2.php. Now how to redirect the same to page3.php depending on the source page from where the user accessed page.php?do=this
$vbulletin->url = "page2.php" . $vbulletin->session->vars['sessionurl'];
if (isset($_SERVER['QUERY_STRING'])) {
eval(print_standard_redirect('redirect_linkdir', true, true));}
Thanks
nexialys
09-17-2008, 10:23 PM
$vbulletin->url already contain the referer page the user was on before clicking the link/button ... if you modify that variable, it is renewed to your new value.
veenuisthebest
09-18-2008, 03:47 AM
and how to go one more page back ?
Dismounted
09-18-2008, 05:21 AM
You can't, unless you keep passing the value on...
veenuisthebest
09-21-2008, 06:07 PM
alright thanks for the help uptill now.
A small question plz:-
I am storing date in unix timestamp format and retrieve it with vbdate(). Fine ! It simply displays in text field.
But I want to retreive it just the way vb does it i.e. in combo/list boxes so that i can edit/update it.
Month Date Year HH MM SS
How to retrieve it in the above format in list boxes with correct date/time selected.
Thank You
Dismounted
09-22-2008, 05:40 AM
$date = explode('-', vbdate('j-n-Y-H-i-s', $dateline));
list($day, $month, $year, $hour, $minute, $second) = $date;
veenuisthebest
09-22-2008, 10:56 AM
oh can't get it work !
see I have this in my PHP
$row_timestamp = explode('-', vbdate('j-n-Y-H-i-s', $result['TIMESTAMP']));
list($day, $month, $year, $hour, $minute, $second) = $row_timestamp;
and $row_timestamp in template.
It displays simple "Array" and no list boxes are displayed too
Marco van Herwaarden
09-22-2008, 10:58 AM
Ofcourse, you are creating an array with explode().
veenuisthebest
09-22-2008, 10:59 AM
ya I can notice that explode is creating a problem. So, how to get it working plz.. ?
Marco van Herwaarden
09-22-2008, 11:08 AM
Well i don't know what you are trying with that explode, so no clue how to correct it. But i doubt you need it at all, try removing it.
Dismounted
09-22-2008, 12:19 PM
You wanted to separate all the "time values" and use them in select boxes - so just use the variables $day, $month, $year, etc., as defined by list().
Do you know what list() does?
veenuisthebest
09-22-2008, 02:31 PM
I had got it working but the small problem that remained with list() was that it INSERTED the selected value at the top in the list box rather than CHOOSING.
So, after lot of fiddling and referring to profile.php (modifyprofile_birthday template) I reached to this:-
$row_timestamp = explode('-', vbdate('j-n-Y-H-i-s', $result['TIMESTAMP']));
$dayselected["$row_timestamp[0]"] = 'selected="selected"';
$monthselected["$row_timestamp[1]"] = 'selected="selected"';
$year = $row_timestamp[2];
$hour = $row_timestamp[3];
$minute = $row_timestamp[4];
$second = $row_timestamp[5];
and in template we can do this way:-
<option value="1" $dayselected[1]>01</option>
<option value="2" $dayselected[2]>02</option>
<option value="3" $dayselected[3]>03</option>
and so on...
Don't you think this is the better way? coz this works perfect and it chooses instead of inserting.
Thanks
Dismounted
09-22-2008, 02:57 PM
Errr - my code does exactly the same as yours - assigning $year/$hour/etc...
$date = explode('-', vbdate('j-n-Y-H-i-s', $dateline));
list($day, $month, $year, $hour, $minute, $second) = $date;
$dayselected["$day"] = 'selected="selected"';
$dayselected["$month"] = 'selected="selected"';
And so on...
veenuisthebest
09-22-2008, 08:57 PM
okk.. I am facing a strange problem now with list boxes.
I am retreiving a score of 1 to 10 in list box. The number 10 is never retrieved/selected. Only happening with 10.
I have this in PHP
$scor = $result['colscore'];
$score["$scor[0]"] = 'selected="selected"';
and in template:-
<select name="scscore" size="1" id="scscore">
<option value="1" $score[1]>1</option>
<option value="2" $score[2]>2</option>
<option value="3" $score[3]>3</option>
<option value="4" $score[4]>4</option>
<option value="5" $score[5]>5</option>
<option value="6" $score[6]>6</option>
<option value="7" $score[7]>7</option>
<option value="8" $score[8]>8</option>
<option value="9" $score[9]>9</option>
<option value="10" $score[10]>10</option></select>
Not sure what i am doing wrong !
Thanks
Dismounted
09-23-2008, 05:34 AM
Have you tried debugging it yourself? Checking every step for the value?
veenuisthebest
09-23-2008, 06:37 AM
oh yes sir, I did check everything, then only i posted.
strange thing is that the scores 1 - 9 are retrieving fine. Its just happening with number 10. When I use text field, it shows fine. Its just some problem with list box selecting 10.
And I just noticed that it is happening with every two digit number like 11, 12 etc. They aren't being selected in the list box. Something with arrays ?
Marco van Herwaarden
09-23-2008, 07:11 AM
Are you sure you have the '10' entry in the array. Arrays are 0-based, so 10 entries wil have the values 0-9.
veenuisthebest
09-23-2008, 07:18 AM
see all I have is this (https://vborg.vbsupport.ru/showpost.php?p=1628019&postcount=15)
What change do I need to make there ?
thanks
veenuisthebest
09-26-2008, 06:14 AM
Can somebody please please look into my problem..... I am not able to figure this out.
I am retrieving a score of 1 to 10 in list box. The number 10 is never retrieved/selected. Only happening with 10. However, 1 to 9 retrieve okay. 10 does show using text field BUT not in list box.
I have this in PHP:-
$scor = $result['colscore'];
$score["$scor[0]"] = 'selected="selected"';
and this in template:-
<select name="scscore" size="1" id="scscore">
<option value="1" $score[1]>1</option>
<option value="2" $score[2]>2</option>
<option value="3" $score[3]>3</option>
<option value="4" $score[4]>4</option>
<option value="5" $score[5]>5</option>
<option value="6" $score[6]>6</option>
<option value="7" $score[7]>7</option>
<option value="8" $score[8]>8</option>
<option value="9" $score[9]>9</option>
<option value="10" $score[10]>10</option></select>
I have no idea what wrong is here.
Thank you.. any help is much appreciated !
Marco van Herwaarden
09-26-2008, 06:23 AM
What is the value of $result['colscore']?
veenuisthebest
09-26-2008, 06:35 AM
any integer between 1 to 10. But when 10 is the value, it doesn't select in list box !
Dismounted
09-26-2008, 06:39 AM
Is that value "10" when it's meant to be "10"?
veenuisthebest
09-26-2008, 06:41 AM
YES... sure !
I told in my second last post that 10 displays fine when using text-field BUT does not select through list box.
Marco van Herwaarden
09-26-2008, 07:09 AM
Then what are you trying with:
$score["$scor[0]"] = 'selected="selected"';
Why use $scor[0] when it is just an text value and not an array? $scor[0] will just return the first character, so if the value is "10" it will return "1":
<?php
$result['colscore'] = "10";
$scor = $result['colscore'];
echo "<br />Var result[colscore]: " . $result['colscore'];
echo "<br />Var scor: " . $scor;
echo "<br />Var scor[0]: " . $scor[0];
?>
PS It is not an integer, but a text with the value "10".
veenuisthebest
09-26-2008, 07:28 AM
$scor[0] will just return the first character, so if the value is "10" it will return "1":
Yes.. I was getting exactly the same problem and I also noticed that this was happening with all 2 digit numbers like 10, 11, 12 and so on.
BUT I just figured it out and this WORKED:-
$scor = explode('-', $result['colscore']);
$score["$scor[0]"] = 'selected="selected"';
I just put explode and its working perfect. But may I know plz what explode did, that the list box is now selecting 2 digit numbers.
Dismounted
09-26-2008, 09:19 AM
An explode makes $result['colscore'] an array, since it is the first and only element, it is assigned the ID of 0. You know you could just have done this:
$score["$result[colscore]"] = 'selected="selected"';
veenuisthebest
10-15-2008, 05:00 AM
I have a similar problem again but this time related to retrieving text values in select box.
I have this in template:-
<select name="category" size="1" id="category">
<option value="Arts and Literature">Arts and Literature</option>
<option value="Blogs and Personal">Blogs and Personal</option>
<option value="Cartoon and Animations">Cartoon and Animations</option>
<option value="Technology">Technology</option>
</select>
Suppose, the value in the database is Technology, How do I retrieve it automatically selected in the select box.
Thank you
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.