Jump to content

LF help

Members
  • Posts

    5
  • Joined

  • Last visited

LF help's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. thank u vry nice trick didnt thought of that does it rly make a difference if u put it on top? i want to say i made the field hidden bcuz it made it look nicer. The final script if (isset($_POST['submit'])) { $QuestionID = $_POST['questionid']; mysql_query("UPDATE fastquestion SET Answered='yes' WHERE questionID='".mysql_real_escape_string($QuestionID)."'") or die(mysql_error()); echo "done"; } $ophalen = mysql_query("SELECT * FROM fastquestion") or die(mysql_error()); while ($gegevens = mysql_fetch_array($ophalen)) { echo "type of the question: ".$gegevens['typequestion']; echo '<br />'; echo "the Question: ".$gegevens['Question']; echo '<br />'; echo "in game name or E-mail: ".$gegevens['ingamenameEmail']; echo '<br />'; echo "already answered: ".$gegevens['Answered']; echo '<br />'; echo "<form name='form1' method='post' action=".$_SERVER['PHP_SELF'].">"; echo "Answered a question? check the question as answered then:"; $QuestionID=$gegevens['questionID']; echo '<br />'; echo '<input type="hidden"name="questionid" value="'.$QuestionID.'" />'; echo '<input value="answered" name="submit" type="submit" />'; echo '</form>'; echo '<hr />'; } ?>
  2. i changed the code a bit to $ophalen = mysql_query("SELECT * FROM fastquestion") or die(mysql_error()); while ($gegevens = mysql_fetch_array($ophalen)) { echo "type of the question: ".$gegevens['typequestion']; echo '<br />'; echo "the Question: ".$gegevens['Question']; echo '<br />'; echo "in game name or E-mail: ".$gegevens['ingamenameEmail']; echo '<br />'; echo "already answered: ".$gegevens['Answered']; echo '<br />'; echo "<Form Name ='form1' Method ='POST' action=" . $_SERVER['PHP_SELF'] . ">"; echo "Answered a question? check the question as answered then:"; $QuestionID=$gegevens['questionID']; echo '<br />'; echo '<input value="answered" name="submit" type="submit">'; echo '</Form>'; echo '<hr />'; } if (isset($_POST['submit'])) { mysql_query("UPDATE fastquestion SET Answered='no' WHERE questionID='$QuestionID'") or die(mysql_error()); echo "done"; } but if i click it now it changes the last value is there anyway to collect the questionID from the one wich is clicked??
  3. I got forms on my site to ask questions to me that works fine i can find them in my database. I recall them with the fetch array module and while. i created this script: $ophalen = mysql_query("SELECT * FROM fastquestion") or die(mysql_error()); while ($gegevens = mysql_fetch_array($ophalen)) { echo "type of the question: ".$gegevens['typequestion']; echo '<br />'; echo "the Question: ".$gegevens['Question']; echo '<br />'; echo "in game name or E-mail: ".$gegevens['ingamenameEmail']; echo '<br />'; echo "already answered: ".$gegevens['Answered']; echo '<br />'; echo '<Form Name ="form1" Method ="POST">'; echo "Answered a question? check the question as answered then:"; echo '<br />'; echo '<input value="answered" name="submit" type="submit">'; echo '</Form>'; echo '<hr />'; if (isset($_POST['submit'])) { $QuestionID=$gegevens['QuestionID']; mysql_query("UPDATE fastquestion SET Answered='yes' WHERE questionID='$QuestionID'") or die(mysql_error()); echo "done"; } } the form and stuff works but ofcourse if i try to submit it changes all values or the last one but it doesnt change the one clicked specific. i understand that it is because of the while but i want to let them only have to click on a button to set the answered tag from no to yes. it would also be an option to use checkboxes but to specify the QuestionID of wich question is answered is difficult because i want the script to fetch all questions submitted to this table.
  4. LF help

    Cgi Form

    i trie to collect form answers too an cgi form the problem is what is the path i have to include in the .cgi file i got this but dont really know the path and if it is supported #!/home/myaccount/rebol -cs
  5. Looking for help with CGI files. I try to include one on my website but it gives an error and sometimes it doesnt show anything. I'am on the Johnny host what i got to do. <!--#include virtual="/cgi-bin/poll.cgi?poll=1" --> actually that is my include for the poll The script contains the following #!usr/bin/perl print "content-type: text/html\n\n" use strict; use CGI qw(:all); my $poll_id = int(param('poll')); my $action; open FH, "poll_${poll_id}_ip.txt"; my $ip = <FH>; close FH; chomp $ip; $ip = defined($ip) ? $ip : ''; if ($ip eq '') { $ip = ':' } my $pat = join('\.', split(/\./, $ENV{'REMOTE_ADDR'})); my $mode = $ip =~ /\:$pat\:/ ? 0 : 1; if (($mode == 0) || defined(param('see'))) { print "Content-Type: text/html\n\n"; print "<center>Poll results</center>\n"; open FH, "poll_${poll_id}_text.txt"; my @lines = <FH>; close FH; print join("<br>", @lines); open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; open FH, "poll_${poll_id}_results.txt"; my @votes = <FH>; close FH; my $sum = 0; foreach (@votes) { $sum += int($_); } print "<center><table border=0 cellspacing=0 cellpadding=4>"; for (my $i = 0; $i <= $#lines; $i++) { my $width = 200; my $a = int($votes[$i] * $width / $sum); my $b = $width - $a; print "<tr><td align=right>$lines[$i] (".int($votes[$i]).")</td><td><table width=$width height=10><tr><td width=$a bgcolor=black></td><td width=$b bgcoloe=blue></td></tr></table></td></tr>"; } print "</table></center>"; } else { if (defined(param('dovote'))) { my $vote = int(param('vote')); open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; if ($vote > $#lines) { print "Content-Type: text/html\n\nError"; exit 0; } open FH, "poll_${poll_id}_results.txt"; my @lines = <FH>; close FH; foreach (@lines) { chomp $_; } $lines[$vote] = int($lines[$vote]) + 1; open FH, ">poll_${poll_id}_results.txt"; print FH join("\n", @lines); close FH; open FH, ">poll_${poll_id}_ip.txt"; print FH "$ip$ENV{'REMOTE_ADDR'}:"; close FH; print redirect(-uri => $ENV{'HTTP_REFERER'}); } else { print "Content-Type: text/html\n\n"; print "<form action=/cgi-bin/poll.cgi method=post>"; print "<input type=hidden name=poll value=$poll_id>"; open FH, "poll_${poll_id}_text.txt"; my @lines = <FH>; close FH; print join("<br>", @lines); print "<center><table border=0 cellspacing=0 cellpadding=4>"; open FH, "poll_${poll_id}_lines.txt"; my @lines = <FH>; close FH; for (my $i = 0; $i <= $#lines; $i++) { print "<tr><td align=center><input type=radio name=vote value=$i></td><td>$lines[$i]</td></tr>"; } print "<tr><td align=center colspan=2><input type=submit name=dovote value=Vote> <input type=submit name=see value=\"See results\"></td></tr>"; print "</table></center>"; print "</form>"; } } my error log says [Tue Feb 28 11:03:07 2012] [error] [client 92.66.136.41] unable to include "cgi-bin/poll.cgi?poll=1" in parsed file /home/jeroenn/public_html/Home.shtml please help me on the page it is showing [an error occurred while processing this directive]
×
×
  • Create New...