السلام عليكم ورحمة الله وبركاتة قمت بعمل اسكريبت بسيط لتصويت
وفكرتة وافكارة انا كتبها فى التعليقات :
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">
<html>
<head>
<title>Title here!</title>
</head>
<body>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #009900;
}
.style1 {
font-weight: bold;
color: #000000;
font-size: 24px;
}
.style3 {font-size: 12}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</head>
<body>
<div id="Layer1" style="position:absolute; left:226px; top:70px; width:275px; height:288px; z-index:1; background-color: #CC0066; layer-background-color: #CC0066; border: 1px none #000000; font-weight: bold; color: #000000; font-size: 24px;">
<form name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="cs" value="radio">
<span class="style3">c#</span></label>
<span class="style3"> <br>
<label>
<input type="radio" name="cplus" value="radio">
c++</label>
<br>
<label>
<input type="radio" name="vb" value="radio">
vb</label>
<br>
</span>
</p>
</form>
<div align="center"><span class="style3">
<input name="submitvote" type="submit" class="style3" id="submit" value="chosse..ok">
</span></div>
</div>
<form name="form2" class="style1" action="<?=$_SERVER['PHP_SELF']?>?selectradio="method="post">
<div align="center">what is the best language ?
</div>
</form>
</body>
</html>
<?php
////////////////////////////////\
/* \\
CREATE TABLE `votes` ( \\
`name` VARCHAR(30) NOT NULL, \\
`votes` INT(5) NOT NULL, \\
PRIMARY KEY (`name`) \\
); \\
*///////////////////////////////\
//we will make general consition for one choose
if (isset( $_GET['selectradio'])) :
// mySQL Stuff
$pass="";
$host="localhost";
$username="";
$database="Vote";
$table="votes";
//connect to database
$link=mysql_connect($host,$username,$pass)or print("Database Connect Error");
//select desire database
mysql_select_db($database,$link)or print"Can Not Open Database";
/*
the name of radio
*/
$cs="c#";
$c_plus="c++";
$vb="vb";
/*we will make condition if user choose any radio
insert into database what he choose */
/*
a => refer to c#
b=> refer to selet c++
c=>refer to select vb
then i will make counter to calculate number of a ,number of b,number of c
and print result of vote
*/
if($_POST['submitvote']=='SUBMIT')
{
if($_POST['CS']=='radio'){
$sql="INSERT INTO $table(name,votes)VALUES('".$_POST['name']."', 'a=1')";
display();}
elseif($_POST['cplus']=='radio'){
$sql="INSERT INTO $table(name,votes)VALUES('".$_POST['name']."', 'b=1')";
display();}
elseif($_POST['vb']=='radio'){
$sql="INSERT INTO $table(name,votes)VALUES('".$_POST['name']."', 'c=1')";
display();}
else{
echo"plz choose your favorit language<br><br>";}
}
//function select and display info about votes
function display()
{//start
$result=mysql_query("SELECT count(votes) FROM $table");
if(!$result)
{
print"<b>Error Performing Query</b>".mysql_error();
exit();
while($row=mysql_fetch_array($result))
{
print("<p>" . $row["votes"] . "</p>");
}
}
}//end
endif;
?>
</body>
</html>