poysyn
01-17-2010, 08:34 AM
Hello,
I have recently decided to make a private messaging system in the site I am making, I got everything set up and now I can't figure out why it doesn't recognize accname as a posted index
My form is here:
<?php
if(!isset($_POST['message'])) {
$call_query = mysql_query("SELECT * FROM accounts ORDER BY id ASC");
echo '<div align="center" class="title">TEZ Employee Call List</div><br />
<form method="post" action="usercp.php?page=employee_call_list">';
echo '<table align="center" cellspacing="0" cellpadding="5" width="100%">
<tr><td class="tableTL" width="33%"><b>Name</b></td><td class="tableTM" width="33%"><b>Phone Number</b></td><td class="tableTR" width="34%"><b>Alt. Phone Number</b></td></tr>';
while($call_data = mysql_fetch_array($call_query)){
$callName = $call_data['name'];
$firstname = $call_data['first'];
$lastname = $call_data['last'];
$call1 = $call_data['acode'];
$call2 = $call_data['first3'];
$call3 = $call_data['last4'];
$calltext = $call_data['text'];
$altcall1 = $call_data['altacode'];
$altcall2 = $call_data['altfirst3'];
$altcall3 = $call_data['altlast4'];
$altcalltext = $call_data['alttext'];
if($calltext == '1'){
$yes = '1';
} else {
$yes = '0';
}
if($altcalltext == '1'){
$altyes = '1';
} else {
$altyes = '0';
}
?>
<tr>
<td class="tableL"><?php echo '<b>' . $firstname . ' ' . $lastname . '</b><br />';
echo '<input type="hidden" name="accname" value="' . $callName . '" />
<input type="submit" name="message" value="Send Mail" />';
?>
</td>
<td class="tableM"><?php echo $call1 . '-' . $call2 . '-' . $call3 . '<br />';
if($yes == '1'){
echo '<b>Able to text!</b>';
}
?>
</td>
<td class="tableR"><?php echo $altcall1 . '-' . $altcall2 . '-' . $altcall3 . '<br />';
if($altyes == '1'){
echo '<b>Able to text!</b>';
}
?>
</td>
<?php
}
?>
</tr>
<?php
echo '</table>';
}
else if(isset($_POST['message'])){
$callNames = $_POST['accname'];
$emp_query = mysql_query("SELECT * FROM accounts WHERE name = '$username'");
$emp_data = mysql_fetch_array($emp_query);
$emp2_query = mysql_query("SELECT * FROM accounts WHERE name = '$callNames'");
$emp2_data = mysql_fetch_array($emp2_query);
?>
<form method="post" action="usercp.php?page=employee_call_list">
<table width="400">
<tr>
<td align="right" valign="top">From:</td>
<td align="left">
<input type="hidden" name="fromfirst" value="<?php echo $emp_data['first']; ?>" />
<input type="hidden" name="fromlast" value="<?php echo $emp_data['last']; ?>" />
<?php echo '<b>' . $emp_data['first'] . ' ' . $emp_data['last'] . '</b>'; ?></td>
</tr>
<tr>
<td align="right" valign="top">To:</td>
<td align="left">
<input type="hidden" name="tofirst" value="<?php echo $emp2_data['first']; ?>" />
<input type="hidden" name="tolast" value="<?php echo $emp_data['last']; ?>" />
<?php echo '<b>' . $emp2_data['first'] . ' ' . $emp2_data['last'] . '</b>'; ?></td>
</tr>
<tr>
<td align="right" valign="top">Message:</td>
<td align="left"><textarea name="message" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="sendmessage" value="Send" /></td>
</tr>
</table>
</form>
<?php
include('includes/pmessage.php');
echo '</form>';
}
?>
And the Handler:
<?php
if(isset($_POST['sendmessage'])){
$fromfirst = $_POST['fromfirst'];
$fromlast = $_POST['fromlast'];
$tofirst = $_POST['tofirst'];
$tolast = $_POST['tolast'];
$message = stripslashes($_POST['message']);
$stop = "false";
echo '<div align="center">';
if (empty($message)) {
echo '<font color="red">Please type a message.</font>';
$stop = "true";
} else {
mysql_query('INSERT INTO messages (abletoview, sent, tofirst, tolast, fromfirst, fromlast, content)
VALUES (1, default, "' . $tofirst . '", "' . $tolast . '", "' . $fromfirst . '", "' . $fromlast . '", "' . $message . '")') OR die (mysql_error());
}
echo '</div>';
}
?>
When I click on the Send button , it returns the error
Notice: Undefined index: accname in C:\wamp\www\includes\user_cp.php on line 190
and line 190 is the part in the code that says $callNames = $_POST['accname'];
If you can help me I would appreciate it very much, and by just reading it I thank you for your interest =)
Thank you in advance,
poysyn
I have recently decided to make a private messaging system in the site I am making, I got everything set up and now I can't figure out why it doesn't recognize accname as a posted index
My form is here:
<?php
if(!isset($_POST['message'])) {
$call_query = mysql_query("SELECT * FROM accounts ORDER BY id ASC");
echo '<div align="center" class="title">TEZ Employee Call List</div><br />
<form method="post" action="usercp.php?page=employee_call_list">';
echo '<table align="center" cellspacing="0" cellpadding="5" width="100%">
<tr><td class="tableTL" width="33%"><b>Name</b></td><td class="tableTM" width="33%"><b>Phone Number</b></td><td class="tableTR" width="34%"><b>Alt. Phone Number</b></td></tr>';
while($call_data = mysql_fetch_array($call_query)){
$callName = $call_data['name'];
$firstname = $call_data['first'];
$lastname = $call_data['last'];
$call1 = $call_data['acode'];
$call2 = $call_data['first3'];
$call3 = $call_data['last4'];
$calltext = $call_data['text'];
$altcall1 = $call_data['altacode'];
$altcall2 = $call_data['altfirst3'];
$altcall3 = $call_data['altlast4'];
$altcalltext = $call_data['alttext'];
if($calltext == '1'){
$yes = '1';
} else {
$yes = '0';
}
if($altcalltext == '1'){
$altyes = '1';
} else {
$altyes = '0';
}
?>
<tr>
<td class="tableL"><?php echo '<b>' . $firstname . ' ' . $lastname . '</b><br />';
echo '<input type="hidden" name="accname" value="' . $callName . '" />
<input type="submit" name="message" value="Send Mail" />';
?>
</td>
<td class="tableM"><?php echo $call1 . '-' . $call2 . '-' . $call3 . '<br />';
if($yes == '1'){
echo '<b>Able to text!</b>';
}
?>
</td>
<td class="tableR"><?php echo $altcall1 . '-' . $altcall2 . '-' . $altcall3 . '<br />';
if($altyes == '1'){
echo '<b>Able to text!</b>';
}
?>
</td>
<?php
}
?>
</tr>
<?php
echo '</table>';
}
else if(isset($_POST['message'])){
$callNames = $_POST['accname'];
$emp_query = mysql_query("SELECT * FROM accounts WHERE name = '$username'");
$emp_data = mysql_fetch_array($emp_query);
$emp2_query = mysql_query("SELECT * FROM accounts WHERE name = '$callNames'");
$emp2_data = mysql_fetch_array($emp2_query);
?>
<form method="post" action="usercp.php?page=employee_call_list">
<table width="400">
<tr>
<td align="right" valign="top">From:</td>
<td align="left">
<input type="hidden" name="fromfirst" value="<?php echo $emp_data['first']; ?>" />
<input type="hidden" name="fromlast" value="<?php echo $emp_data['last']; ?>" />
<?php echo '<b>' . $emp_data['first'] . ' ' . $emp_data['last'] . '</b>'; ?></td>
</tr>
<tr>
<td align="right" valign="top">To:</td>
<td align="left">
<input type="hidden" name="tofirst" value="<?php echo $emp2_data['first']; ?>" />
<input type="hidden" name="tolast" value="<?php echo $emp_data['last']; ?>" />
<?php echo '<b>' . $emp2_data['first'] . ' ' . $emp2_data['last'] . '</b>'; ?></td>
</tr>
<tr>
<td align="right" valign="top">Message:</td>
<td align="left"><textarea name="message" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="sendmessage" value="Send" /></td>
</tr>
</table>
</form>
<?php
include('includes/pmessage.php');
echo '</form>';
}
?>
And the Handler:
<?php
if(isset($_POST['sendmessage'])){
$fromfirst = $_POST['fromfirst'];
$fromlast = $_POST['fromlast'];
$tofirst = $_POST['tofirst'];
$tolast = $_POST['tolast'];
$message = stripslashes($_POST['message']);
$stop = "false";
echo '<div align="center">';
if (empty($message)) {
echo '<font color="red">Please type a message.</font>';
$stop = "true";
} else {
mysql_query('INSERT INTO messages (abletoview, sent, tofirst, tolast, fromfirst, fromlast, content)
VALUES (1, default, "' . $tofirst . '", "' . $tolast . '", "' . $fromfirst . '", "' . $fromlast . '", "' . $message . '")') OR die (mysql_error());
}
echo '</div>';
}
?>
When I click on the Send button , it returns the error
Notice: Undefined index: accname in C:\wamp\www\includes\user_cp.php on line 190
and line 190 is the part in the code that says $callNames = $_POST['accname'];
If you can help me I would appreciate it very much, and by just reading it I thank you for your interest =)
Thank you in advance,
poysyn