⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vote.htm

📁 javascript source code part2
💻 HTM
字号:
<HTML>
<HEAD>
<TITLE>
Voting Page
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
<SERVER>
//get the voter uid
var user = client.user;

var voteConn = null; // voting db connection

// get the connection
// name connection for debugging purposes
// set server timeout to 10 seconds
voteConn = project.appPool.connection("checkVoters",10);

if (voteConn == null)
{
   write('<font color="#ff0000">Error: Unable to connect to database</FONT>');
 
}


// all registered voters should be pre-populated into the database
// build the cursor to handle results
sql = "SELECT voter.uid, voter.hasvoted FROM voter WHERE (voter.uid = '"+ user + "')";
var voterCursor = voteConn.cursor(sql);

if (!voterCursor.next())
{
  write('<h2> No voter found matching: ' + user + '</h2>');
  client.user = "";

  //here we allow the user to try again
  // in a real application, something should at least logged
  write('<A HREF="login.htm">Try again</A>');
}

// we got a "real" voter
else
{

   // check to see if they have voted yet
   // we don't want any ballot stuffing ;)
   
   if ( voterCursor.hasvoted == 1)
   {
      write('<h2> voter: '+ user + ' has voted</h2>');
      //again we should do better error handling
      write('<A HREF="login.htm">Try again</A>');
   }
   else 
   {
       //okay you can vote!
       //first close the cursor
       voterCursor.close();
       //next release current connection
       voteConn.release();
       // now the user can go to the voting booth
       redirect("ballot.htm");
   }


}

</SERVER>
</BODY>
</HTML>>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -