Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-02-2007, 02:06 PM
webek's Avatar
Novice Webmaster
 
Join Date: Aug 2004
Location: Kuching, Sarawak
Posts: 27
Rep Power: 0
webek is on a distinguished road
Simple Poll/Quiz script

Dalam boring-boring buat membership script, aku terbuat pulak script polling/quiz.

Fail-fail:
fail poll - index.php
blank file - terkini.php
blank fail - terdahulu.php
image - line.gif

[DEMO - sarawaknet.t35.com/poll.php]
[PASS - pass123]



<table cellpadding=0 cellspacing=5>
<tr><td bgcolor=#CDF47>
<a href="index.php">Terkini</a> | <a href="index.php?DO=terdahulu">Terdahulu</a> | <a href="index.php?DO=admin">Admin</a>
</td></tr>
<tr><td>
<?php

poll();

function poll()
{
if (get_magic_quotes_gpc())
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
}
// Senarai poll
if ($_GET['DO']=="")
{
include "terkini.php";
?>
<table cellpadding=0 cellspacing=0>
<tr>
<td colspan=2 align=left valign=middle>
<form>
<input type=hidden name=DO value="scriptpoll">
<input type=hidden name=soalan value="<? echo $soalan; ?>">
<input type=hidden name=jawab1 value="<? echo $jum1; ?>">
<input type=hidden name=jawab2 value="<? echo $jum2; ?>">
<input type=hidden name=jawab3 value="<? echo $jum3; ?>">
<input type=hidden name=jawab4 value="<? echo $jum4; ?>">
<input type=hidden name=jawab5 value="<? echo $jum5; ?>">
<input type=hidden name=soalan1 value="<? echo $soalan1; ?>">
<input type=hidden name=soalan2 value="<? echo $soalan2; ?>">
<input type=hidden name=soalan3 value="<? echo $soalan3; ?>">
<input type=hidden name=soalan4 value="<? echo $soalan4; ?>">
<input type=hidden name=soalan5 value="<? echo $soalan5; ?>">
<b><? echo $soalan; ?></b>
</td>
</tr>
<tr><td width=10%><input type=checkbox name=soal1 value="1"></td><td><? echo $soalan1; ?></td></tr>
<tr><td width=10%><input type=checkbox name=soal2 value="1"></td><td><? echo $soalan2; ?></td></tr>
<tr><td width=10%><input type=checkbox name=soal3 value="1"></td><td><? echo $soalan3; ?></td></tr>
<tr><td width=10%><input type=checkbox name=soal4 value="1"></td><td><? echo $soalan4; ?></td></tr>
<tr><td width=10%><input type=checkbox name=soal5 value="1"></td><td><? echo $soalan5; ?></td></tr>
<tr><td width=10%>.</td><td><input type=submit value=Hantar> <a href="index.php?DO=keputusan">Keputusan</a></td></tr>
</table>
</form>
<?
}
//script poll
if ($_GET['DO']=="scriptpoll")
{
$soalan= $_GET['soalan'];
$jawab1= $_GET['jawab1'];
$jawab2= $_GET['jawab2'];
$jawab3= $_GET['jawab3'];
$jawab4= $_GET['jawab4'];
$jawab5= $_GET['jawab5'];
$soal1= $_GET['soal1'];
$soal2= $_GET['soal2'];
$soal3= $_GET['soal3'];
$soal4= $_GET['soal4'];
$soal5= $_GET['soal5'];
$sum1=$jawab1+$soal1;
$sum2=$jawab2+$soal2;
$sum3=$jawab3+$soal3;
$sum4=$jawab4+$soal4;
$sum5=$jawab5+$soal5;
$soalan1= $_GET['soalan1'];
$soalan2= $_GET['soalan2'];
$soalan3= $_GET['soalan3'];
$soalan4= $_GET['soalan4'];
$soalan5= $_GET['soalan5'];
$tarikh= date("j F Y, g:i a");
$file = fopen('terkini.php', 'w');
$d="<?
\$soalan=\"$soalan\";\n
\$jum1=\"$sum1\";
\$jum2=\"$sum2\";
\$jum3=\"$sum3\";
\$jum4=\"$sum4\";
\$jum5=\"$sum5\";
\$soalan1=\"$soalan1\";\n
\$soalan2=\"$soalan2\";\n
\$soalan3=\"$soalan3\";\n
\$soalan4=\"$soalan4\";\n
\$soalan5=\"$soalan5\";\n
?>";
fwrite($file, $d);
fclose($file);
die("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url='index.php?DO=keputusan'\">");
}
else if ($_GET['DO']=="keputusan") // jurnal baru
{
include "terkini.php";
?>
<table cellpadding=0 cellspacing=0>
<tr>
<td align=left valign=middle>
<b><? echo $soalan; ?></b>
</td>
</tr>
<tr><td> <? echo $soalan1; ?><br><img src='line.gif' height=10 width="<? echo $jum1; ?>"> <? echo $jum1; ?></td></tr>
<tr><td> <? echo $soalan2; ?><br><img src='line.gif' height=10 width="<? echo $jum2; ?>"> <? echo $jum2; ?></td></tr>
<tr><td> <? echo $soalan3; ?><br><img src='line.gif' height=10 width="<? echo $jum3; ?>"> <? echo $jum3; ?></td></tr>
<tr><td> <? echo $soalan4; ?><br><img src='line.gif' height=10 width="<? echo $jum4; ?>"> <? echo $jum4; ?></td></tr>
<tr><td> <? echo $soalan5; ?><br><img src='line.gif' height=10 width="<? echo $jum5; ?>"> <? echo $jum5; ?></td></tr>
</table>
<?
}
else if ($_GET['DO']=="terdahulu") // script baru
{
include "terdahulu.php";
}
else if ($_GET['DO']=="admin") // login
{
?>
<form>
<input type=hidden name=DO value="scriptadmin">
<table cellpadding=0 cellspacing=0>
<tr><td align=left valign=middle>Soalan</td><td><input type=text size=30 name=soalan></td></tr>
<tr><td width=10% valign=top>Jawapan</td><td valign=top>
1. <input type=text size=27 name=soalan1><br>
2. <input type=text size=27 name=soalan2><br>
3. <input type=text size=27 name=soalan3><br>
4. <input type=text size=27 name=soalan4><br>
5. <input type=text size=27 name=soalan5><br>
</td></tr>
<tr><td align=left valign=middle>Password</td><td><input type=text size=30 name=password></td></tr>
<tr><td width=10%>.</td><td><input type=submit value=Hantar></td></tr>
</table>
</form>
<?
}
//script admin
else if ($_GET['DO']=="scriptadmin")
{
$adminpass = "pass123";
$password = $_GET['password'];
if ($password==$adminpass) {

// polah data dari poll terkini
include "terkini.php";
$c1="<table cellpadding=0 cellspacing=0><tr><td align=left valign=middle><b>".$soalan."</b></td></tr>
<tr><td>".$soalan1."<br><img src='line.gif' height=10 width=".$jum1."> ".$jum1."</td></tr>
<tr><td>".$soalan2."<br><img src='line.gif' height=10 width=".$jum2."> ".$jum2."</td></tr>
<tr><td>".$soalan3."<br><img src='line.gif' height=10 width=".$jum3."> ".$jum3."</td></tr>
<tr><td>".$soalan4."<br><img src='line.gif' height=10 width=".$jum4."> ".$jum4."</td></tr>
<tr><td>".$soalan5."<br><img src='line.gif' height=10 width=".$jum5."> ".$jum5."</td></tr>
</table><hr>\n";

$soalan= $_GET['soalan'];
$soalan1= $_GET['soalan1'];
$soalan2= $_GET['soalan2'];
$soalan3= $_GET['soalan3'];
$soalan4= $_GET['soalan4'];
$soalan5= $_GET['soalan5'];

// data tedahulu.php
$f2 = fopen("terdahulu.php",'rb');
if ($f2==FALSE) die($chmodError);
flock($f2,LOCK_SH);
@$c2 = fread($f2, filesize("terdahulu.php"));
flock($f2,LOCK_UN);
fclose($f2);

// cantum dua2 data ya sebagai terdahulu.php
$f3 = fopen("terdahulu.php",'wb');
if ($f3==FALSE) die($chmodError);
flock($f3,LOCK_EX);
fwrite($f3, $c1.$c2);
flock($f3,LOCK_UN);
fclose($f3);

// data terkini batu
$file = fopen('terkini.php', 'w');
$d="<?
\$soalan=\"$soalan\";\n
\$jum1=\"0\";
\$jum2=\"0\";
\$jum3=\"0\";
\$jum4=\"0\";
\$jum5=\"0\";
\$soalan1=\"$soalan1\";\n
\$soalan2=\"$soalan2\";\n
\$soalan3=\"$soalan3\";\n
\$soalan4=\"$soalan4\";\n
\$soalan5=\"$soalan5\";\n
?>";
fwrite($file, $d);
fclose($file);
die("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url='index.php'\">");
} else {
echo("<script>alert('Login Gagal! Password [".$password."] tidak tepat')</script>");
die("<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=index.php?DO=admin\">");
}
}
//fungsi tamat
}
?>
</td></tr>
</table>
__________________
http|//www.jelajahborneo.uni.cc
Semuanya Bermula Di Sini!

Last edited by webek; 06-02-2007 at 03:19 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-02-2007, 02:24 PM
yipguseng's Avatar
Lost Webmaster
 
Join Date: Jan 2007
Location: Petaling Jaya
Posts: 857
Rep Power: 42
yipguseng will become famous soon enough yipguseng will become famous soon enough
Send a message via MSN to yipguseng
err..is it a success script? or got bug/error?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-02-2007, 02:28 PM
webek's Avatar
Novice Webmaster
 
Join Date: Aug 2004
Location: Kuching, Sarawak
Posts: 27
Rep Power: 0
webek is on a distinguished road
working script

Boleh test kat [HTTP]sarawaknet.t35.com. Free hosting with a lot of pop up banner.
__________________
http|//www.jelajahborneo.uni.cc
Semuanya Bermula Di Sini!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Blog Script webek Blogging Discussion 5 22-11-2007 12:06 PM
Winners of Merdeka Quiz 2006 starsearcher News and Announcements 3 24-09-2006 04:38 PM
Merdeka Quiz 2006 starsearcher Web Hosting Offers 1 08-08-2006 04:52 PM
poll/vote script lcf Website Programming 4 10-08-2005 10:05 AM
Online Poll PHP script MENJ Website Programming 2 13-10-2004 05:34 PM



All times are GMT +8. The time now is 05:37 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60