Scroll-Down Lists Help

DoubleDraGoN

New Member
Reaction score
2
Hi I have the HTML I just need to know how to get the information stored from the user's choice

Heres the code:
<SELECT NAME="video game" SIZE=3>
<OPTION VALUE="nintendo64">Nintendo 64
<OPTION VALUE="playstation">Sony Playstation
<OPTION VALUE="dreamcast">Sega Dreamcast
<OPTION VALUE="arcade">Arcade Games
</SELECT><P>

So heres a list of what video game they like, the user clicks one of the options and clicks submit and heres the code for that

<INPUT TYPE="submit" VALUE="Submit">

Now all I need is the way to store that information so I can display the results of the poll/quiz. TY for help btw
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
What programming language are you using on the servers side? Mind posting the <form> tag too?
 
S

Storm

Guest
Doesn't the <option> tag have an </option> closing tag? :confused:

EDIT: This might help...

EDITEDIT: Taken back. Apparently it was bad coding.
 

enouwee

Non ex transverso sed deorsum
Reaction score
240
SCRIPT_PATH.php -
PHP:
<?php

$file = fopen("BLANK_TXT_FILE.txt", "a");
file_put_contents("BLANK_TXT_FILE.txt", $_POST['video_game'] . '<br />', FILE_APPEND);
fclose($file);
echo "Thank you. Your selection " . $_POST['video_game'] . " has been added.<br /><center><a href='THE_DISPLAY_PAGE.php'>Back</a></center>";
?>

This is very bad code. Not only are you not locking the file to make sure than only one PHP process manipulates the file at the same time, but you're not verifying user input.

Either use fopen()/fclose() or file_put_contents() but not both at the same time. file_put_contents takes a filename as argument and not a file handle.

  1. Locking
    • Users A and B submit their votes at the same time
    • process A opens the file for appending, gets interrupted. It's file handle points at the end of the file.
    • process B opens the file for appending, it's file points to the same place
    • process B appends its entry to the end of file and closes its handle
    • process A appends its entry to the end of file and closes its handle
    Result: occasional data corruption. The entry of user B is (partially) overwritten by user A.

    Correct way to implement such a thing: process B should wait for process A to finish before modifying the file. This is accomplished by using flock() or passing the LOCK_EX flag to the file_put_contents functions. Note that file_get_contents doesn't have a locking parameter, so don't use them at all.

    You'd also better add a "\n" to the string you're saving, because file_put_contents() automagically put one for you.
  2. User input
    I'm POST'ing this:
    Code:
    video_game\nvideo_game\nvideo_game\nxbox
    I just voted 4x and added an answer that shouldn't even be there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top