vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   vote/rate add-on query (https://vborg.vbsupport.ru/showthread.php?t=58867)

sabret00the 11-29-2003 11:14 AM

thanks assassin, you've been a great help, i've got to final stages of this end of things, which means it'll be fully usable soon, all bar one thing, in my script, i'm processing the ratings via
PHP Code:

 if (isset'confess_rate' && $rate && $confessionid != '' && $bbuserinfo[userid] > 0) {

  
$flood $DB_site->query("SELECT timestamp FROM confessions ORDER BY timestamp DESC LIMIT 1");
  
$check $DB_site->fetch_array($flood);

  if ((
time() - $check[timestamp]) <= 10) {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
 }
  if (
$bbuserinfo[userid] == $DB_site->query("SELECT userid FROM confession_rate WHERE confessionid = $confessionid")) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
  } else {
   
$DB_site->query("INSERT INTO confession_rate SET
   confessionid = '
$confessionid',
   userid = '
$bbuserinfo[userid]',
   rate = '
$rate',
   timestamp = '"
.time ()."'");
  }
  
header("Location: $PHP_SELF?s=");
 } else {
  
header("Location: $PHP_SELF?s=");
 } 

but it won't submit to the database, what am i doing wrong?

assassingod 11-29-2003 11:18 AM

If you're implenting this into vB, you'd want to do something like:
PHP Code:

####### display form #######
if (!isset($_POST['process']) or $_POST['process'] == '')
{
//display vb and form stuff
}
 
// ###### start insert ######
if (isset($_POST['process']) and $_POST['process'] != '' and $_POST['process'] == 'go')
{
//vb stuff and insert into DB stuff


Not sure if that'll be a great deal of help, used it from my mailing list hack

sabret00the 11-29-2003 11:37 AM

sorry assassin, that was experimental code, heres what i was doing properly
PHP Code:

 case "voting":
// this conditional handles the rating
if ('confess_rate' && $rate && $confessionid != '' && $bbuserinfo[userid] > 0) {
$flood $DB_site->query("SELECT timestamp FROM confessions ORDER BY timestamp DESC LIMIT 1");
$check $DB_site->fetch_array($flood);
if ((
time() - $check[timestamp]) <= 10) {
eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
}
if (
$bbuserinfo[userid] == $DB_site->query("SELECT userid FROM confession_rate WHERE confessionid = $confessionid")) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
} else {
$DB_site->query("INSERT INTO confession_rate SET
confessionid = '
$confessionid',
userid = '
$bbuserinfo[userid]',
rate = '
$rate',
timestamp = '"
.time ()."'");
}
header("Location: $PHP_SELF?s=");
} else {
header("Location: $PHP_SELF?s=");
}
    break; 

but i'll try the using the super globals :)

ps. this is just the form processing, the actual form display elsewhere in the document.

heres the link to where this is all happening http://www.ebslive.com/confessions/i...onfessionid=49

sabret00the 11-29-2003 01:32 PM

HTML Code:

<form method="post" name="confess_rate" action="?do=voting">
<input type="hidden" name="$confessionid">
<input type="hidden" name="$bbusername">
<table width="80%">
  <tr>
        <td align="center" colspan="2" nowrap>
          <smallfont>rate how good you think this confession is</smallfont><br />
          <input type="radio" name="rate" value="1" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="2" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="3" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="4" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="5" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="6" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="7" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="8" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="9" onclick="document.confess_rate.submit()">
          <input type="radio" name="rate" value="10"onclick="document.confess_rate.submit()">
        </td>
  </tr>
  <tr>
        <td align="left" width="50%"><smallfont>Saint</smallfont></td>
        <td align="right" width="50%"><smallfont>Sinner</smallfont></td>
  </tr>
  <tr>
        <td align="center" colspan="2"><br>
          <smallfont>this confession currently has a rating of $confession_avg_rate</smallfont>
        </td>
  </tr>
</table>
</form>

is the form that submits the data :)

sabret00the 11-29-2003 07:30 PM

lol, i was standing in the kebab shop when i finally got what you meant, thanks steven, took me all day but i got there in the end, gonna try it now :)

assassingod 11-29-2003 07:33 PM

Quote:

Originally Posted by sabret00the
lol, i was standing in the kebab shop when i finally got what you meant, thanks steven, took me all day but i got there in the end, gonna try it now :)

hehe, nothing like food the make you think:D

Hope it goes ok.

sabret00the 11-29-2003 10:17 PM

got the code down from 25 lines to 17 but it's still not working, i think this is down to the actual form rather than the coding tho.
PHP Code:

  // this conditional handles the rating
  
if ($_POST['submit'] == 'confess_rate') {
   
$confessionid intval($_POST['confessionid']);
   
$verify $DB_site->query_first("SELECT userid FROM confession_rate WHERE confessionid = $confessionid AND userid = $bbuserinfo[userid]");
   if (
$verify) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
   } else {
    
$DB_site->query("INSERT INTO confession_rate SET
    confessionid = '
$confessionid',
    userid = '
$bbuserinfo[userid]',
    rate = '
$rate',
    timestamp = '"
.time ()."'");
 
    
header("Location: $PHP_SELF?s="); //takes you back to main confession page
   
}
  } else {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
  } 


assassingod 11-29-2003 10:27 PM

*takes time away from his new hack*

Try using:
PHP Code:

if($action=="displayform")
{
// form code here
}
if (
$HTTP_POST_VARS['action']=="processform")
{
// queries and stuff


Then for the form tag, you would use something like
Code:

<form action="pagehere.php" method="post"><input type="hidden" name="s" value="$session[dbsessionhash]">
<!-- form code -->
 <input type="hidden" name="action" value="processform">
 <input type="submit" class="bginput" name="Submit" value="Submit Tutorial" accesskey="s">

</form>

You'll need to edit that a bit but thats a better way of doing from what i said earlier

Also, use the standardredirect function instead of header("locaion:");

sabret00the 11-30-2003 11:47 AM

i'm getting so close to giving up on this, i dunno what's wrong with it, i've tried so many methods, but it's not passing to the database, infact i get the error i set up to say the vote cannot be processed :(

PHP Code:

  if ($_POST['submit'] == "rate") {
   
$confessionid intval($_POST['confessionid']);
   
$verify $DB_site->query_first("SELECT userid FROM confession_rate WHERE confessionid = $confessionid AND userid = $bbuserinfo[userid]");
   if (
$verify) {
    eval(
"standarderror(\"".gettemplate("confession_error_novotetwice")."\");");
   } else {
    
$DB_site->query("INSERT INTO confession_rate SET
    confessionid = '
$confessionid',
    userid = '
$bbuserinfo[userid]',
    rate = '
$rate',
    timestamp = '"
.time ()."'");
 
    
header("Location: $PHP_SELF?s="); //takes you back to main confession page
   
}
  } else {
   eval(
"standarderror(\"".gettemplate("confession_error_vote")."\");");
  } 

arghhh, i think i just found it, i tried to pass the username with the form and not the userid :mad: will check it now :)

sabret00the 11-30-2003 12:00 PM

edit, it was such a stupid mistake
HTML Code:

<input type="hidden" name="$confessionid">
<input type="hidden" name="$bbusername">

should have been
HTML Code:

<input type="hidden" name="confessionid" value="$confessionid">
<input type="hidden" name="userid" value="$bbuserinfo[userid]">

:lol: it's still not working yet, but i'm a step closer :)


All times are GMT. The time now is 01:29 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.01109 seconds
  • Memory Usage 1,802KB
  • 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
  • (3)bbcode_html_printable
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)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