please help me...i need some help from you all....because i still new in writhing php code.
thanks...
actually right now im doing a vote list name member for the committee members. so, the name for the list Committee members i take from my database. After that, i want when the people click submit when the name already chosen ....the data must insert into database but in difference table.
here is my code.....
first page i rename it select.php
<?
session_start ();
include "connection.php";
mysql_connect ("$host", "$username", "$password") or die ("cannot connect");
mysql_select_db ("$db_name") or die ("cannot select DB");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="save.php">
<table width="35%" border="1" align="center">
<tr>
<td colspan="2">Who you want to vote as a ......</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="9%" height="26">Chairman</td>
<td>
<label>
<select name="select1" id="select" >
<?
$sql = "select UserName from advlogin order by UserName ASC";
$rs = mysql_query($sql) or die (mysql_error());
if ($rs)
{
while ($rw = mysql_fetch_object($rs))
{
$UserName=$rw->UserName;
?>
<option value="<? echo $UserName; ?>"<?php if(!empty($row['option']) and ($row['option'] == "$UserName")) { echo(" selected=\"selected\""); }?>><? echo $UserName; ?> </option>
<?
}
}
?>
</select>
</label>
</td>
</tr>
<tr>
<td> </td>
<td><label>
<input type="submit" name="button" value="Submit">
</label></td>
</tr>
</table>
</form>
</body>
</html>
here is my save.php code...
<?
include "con3.php";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$UserName = $_POST['UserName'];
$sql="insert into vote(name)values('$name')";
mysql_query($sql) or die(mysql_error());
?>
<style type="text/css">
<!--
body {
background-color: #D5EDB3;
}
-->
</style><HEAD>
<script type = "text/javascript">
window.location="#"
</script>
the problem is...when i select the name and click submitt..it works but..the name doesn't insert into my database.
...
please help me... :(