update.php
<?php
session_start();
if (!isset($_SESSION['user']))
{
die ("Access Denied");
}
if ($_POST['submit']=='Update Information')
{
$name_box = $_REQUEST['name_box'];
while (list ($key_check,$val_check) = @each ($name_box))
{ $value_check .= $val_check.",";
}
$all_value_check = substr($value_check, 0, -1);
}
?>
<?php
include 'dbc.php';
$user = $_SESSION['user'];
$query = "SELECT * FROM student WHERE user_email = '$user'";
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_NUM))
{
echo
"
<html><head><script type='text/javascript'>
function check()
{
var c_value = '';
for (var i=0; i < document.length; i++)
{
if (document.pro.name_box[i].checked)
{
c_value = c_value + document.pro.name_box[i].value + '\n';
}
}
}
</script>
</head>".
"<form action='processupdate.php' method='post' name='pro'> <table border=1>".
"<tr><td colspan=4 width=15% bgcolor=black><font color=white><h1>Registered User ID: $row[0]</font></td>".
"</tr>".
"<tr><td>Interested in the following Musical Instruments: <br> (current)</td><td>". $row[14].
" <td align='right'>Update to: <br>(new)</td>
<td colspan=2 align=left>
<input name='name_box[]' type='checkbox' value='Cello' />Cello <br>
<input name='name_box[]' type='checkbox' value='Flute' />Flute <br>
<input name='name_box[]' type='checkbox' value='Clarinet' />Clarinet <br>
<input name='name_box[]' type='checkbox' value='Saxophone' />Saxophone <br>
<input name='name_box[]' type='checkbox' value='Vocal' />Vocal <br>
</td>".
"<tr><td colspan=4><input type='submit' name='submit' value='Update Information' style='height: 35px; width: 100%'></td></tr></table></form>";
}
?>
processupdate.php
<?php session_start();
if (!isset($_SESSION['user'])){ die ("Access Denied"); } ?>
<?php if (isset($_SESSION['user']))
include ('dbc.php');
$server = $_SERVER['HTTP_HOST'];
$host = ereg_replace('www.','',$server);
$user = $_SESSION['user'];
$full_name = addslashes($_REQUEST['full_name']);
$email = addslashes($_REQUEST['email']);
$hp = addslashes($_REQUEST['hp']);
$loc = ($_REQUEST['loc']);
$cloc = ($_REQUEST['cloc']);
//$test = ($_REQUEST['name_box']);
$test = addslashes ($_REQUEST['name_box']);
$test2 = $_REQUEST['c_value'];
";
//run function
$query = "SELECT * FROM student WHERE user_email = '$user'";
$data = mysql_query("SELECT image FROM em.testblob") or die(mysql_error());
$result = mysql_query($query);
while($row=mysql_fetch_array($result, MYSQL_NUM))
{
/*
*/
/*echo $row[1].$row[4].$row[10].$row[11].$row[12].$row[14];*/
echo $full_name. $test. $test2;
$sql = "UPDATE student SET full_name = '$full_name' , user_email = '$email' , hp = '$hp' , plocation = '$loc' , llocation = '$cloc' , test = '$test' WHERE id = '$row[0]'";
$result = MYSQL_QUERY($sql);
echo $_SESSION['user'];
echo $user;
exit;
}
{ ?>
<?php } ?>
i cant seems to get the array when i post the checkbox to another page......tried javascript
the variable i requested becomes the word "Array".
Notice: Array to string conversion in C:\wamp\www\em\student\processupdate.php on line 19