Current location: Hot Scripts Forums » Programming Languages » PHP » form not inserting information into the database


form not inserting information into the database

Reply
  #1 (permalink)  
Old 11-30-03, 04:27 PM
sabret00the sabret00the is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy form not inserting information into the database

i wondered if you could help, i've got this form set up

PHP Code:

<form method="post" name="confess_rate" action="?do=voting">
<
input type="hidden" name="confessionid" value="$confessionid">
<
input type="hidden" name="userid" value="$bbuserinfo[userid]">
<
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
and i want insert the information into the database, it's a rating system, for this i've set up this code
PHP Code:

  // this conditional handles the rating
  
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")."\");"); //page i keep being taken too
  

yet it's just not doing it, every time i try and rate something, i get the error designated by " eval("standarderror(\"".gettemplate("confession_er ror_vote")."\");"); " i wondered if you could help me to get this working please.
Reply With Quote
  #2 (permalink)  
Old 11-30-03, 05:35 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
Are your global variables turned off? If so, you need do use a $_POST in your php form to get the values from the input form.
Reply With Quote
  #3 (permalink)  
Old 11-30-03, 05:48 PM
Chroder Chroder is offline
Newbie Coder
 
Join Date: Sep 2003
Location: Toronto, Ontario
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
if ($_POST['submit'] == "rate") {
I don't see any form element with the name "submit" and the value "rate". Instead of having the form auto-submit with the click of the radio button, just add a submit button.

Code:
<input type="subimt" name="submit" value="rate" />
__________________
DevBox.net | DevBoxForums.com
Reply With Quote
  #4 (permalink)  
Old 11-30-03, 05:57 PM
mdhall's Avatar
mdhall mdhall is offline
Aspiring Coder
 
Join Date: Oct 2003
Posts: 510
Thanks: 1
Thanked 1 Time in 1 Post
I was wondering about this...

action="?do=voting">

Why the "?" is there. Is that part of the script name?
Reply With Quote
  #5 (permalink)  
Old 11-30-03, 06:26 PM
sabret00the sabret00the is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
sorry about this, i figured it out by changing
PHP Code:

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

instead of
PHP Code:

 if ($_POST['submit'] == "rate") { 

and it worked fine
Reply With Quote
  #6 (permalink)  
Old 12-01-03, 03:16 PM
lordmerlin lordmerlin is offline
Newbie Coder
 
Join Date: Jul 2003
Location: South Africa
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by sabret00the
sorry about this, i figured it out by changing
PHP Code:

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

instead of
PHP Code:

 if ($_POST['submit'] == "rate") { 

and it worked fine
I use an immage for the submit button, as bellow:
<input name="submit" type="image" value="apply" src="images/but_submit.gif" alt="Submit" width="66" height="17" border="0">

Yet, I can't seem to access the variable via
if ($_POST['submit'] == "apply") {

Is there any other way I can see if this form is submitted?
Reply With Quote
  #7 (permalink)  
Old 12-01-03, 03:34 PM
sabret00the sabret00the is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
post the whole form markup and i'll take a look
Reply With Quote
  #8 (permalink)  
Old 12-01-03, 03:35 PM
sabret00the sabret00the is offline
New Member
 
Join Date: Nov 2003
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mdhall
I was wondering about this...

action="?do=voting">

Why the "?" is there. Is that part of the script name?
it's part of an internal switch function
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL database registration form help vinhkhuong PHP 3 10-10-03 03:49 AM
asp: URGENT! need to change code to create new form per id seala ASP 2 09-09-03 09:54 PM
asp: checkboxes & multi-page form seala ASP 0 09-02-03 01:58 PM
Need to submit form to database and text file - Any ideas how? dpreiss ASP 1 08-21-03 06:02 PM


All times are GMT -5. The time now is 06:03 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.