...

View Full Version : Index posting error



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

Len Whistler
01-17-2010, 08:44 AM
This post may offer a solution and explanation:

http://www.codingforums.com/showthread.php?p=910585#post910585

$callNames = $_POST['accname'];

try:

$callNames = $_POST["accname"];


And if you still get the warning this in the header should work:

error_reporting(0);





---------

poysyn
01-17-2010, 08:55 AM
This post may offer a solution and explanation:

http://www.codingforums.com/showthread.php?p=910585#post910585

$callNames = $_POST['accname'];

try:

$callNames = $_POST["accname"];


And if you still get the warning this in the header should work:

error_reporting(0);





---------


what do you mean by "in the header" ?

bdl
01-17-2010, 08:55 AM
That's not a form, that's a PHP script. Please be sure to post the HTML markup that PHP outputs, not the PHP itself.

Len Whistler
01-17-2010, 08:57 AM
what do you mean by "in the header" ?


header.php file if you have one.


--------------

poysyn
01-17-2010, 09:05 AM
That's not a form, that's a PHP script. Please be sure to post the HTML markup that PHP outputs, not the PHP itself.

bdl, Yes its a php script but the html script does not display any errors so i had to pst the php script.

here is the html output for the form:





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEZ - Control Panel</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
a, a:visited { color: #666666 }
a:hover { color: #999999 }
.title { color: #333333 }
.banner { background: url(images/banner_tez.png) no-repeat; }
</style></head>
<body>
<div class="container">
<div class="main">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="539" height="110" style="margin-top: -300px;">
<param name="movie" value="banner_redtez.swf" />
<param name="quality" value="best" />
<param name="menu" value="true" />
<param name="allowScriptAccess" value="always" />

<embed src="images/banner_redtez.swf" quality="best" menu="true" width="539" height="110" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always">
</embed>
</object>
<div class="navLeft"></div>
<div class="navCenter"><a href="index.php">HOME</a>
<a href="usercp.php">USER CP</a>
<a href="usercp.php?page=request">REQUEST</a>
<a href="usercp.php?page=manage">MANAGE</a>

<a href="calendar/index.php">CALENDAR</a>
<a href="usercp.php?page=logout">LOGOUT</a></div>
<div class="navRight"></div><br />
<div class="contentContainer">
<div class="navReflection"></div>
<div class="content">
<div align="center" class="title">TEZ Employee Call List</div><br />

<form method="post" action="usercp.php?page=employee_call_list"><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>
<tr>

<td class="tableL"><b>*********</b><br /><input type="hidden" name="accname" value="TEZadmin" />
<input type="submit" name="message" value="Send Mail" /> </td>

<td class="tableM">925-123-4567<br /> </td>

<td class="tableR">925-123-4567<br /> </td>

</tr>
</table> </div>
<div class="sidebar">
<img src="images/sidebar_info.gif" alt="Information" /><div class="sidebarItem">

<div class="sidebarLeft">Total Employees</div><div class="sidebarRight">2</div><br />
<div class="sidebarLeft">Total Managers</div><div class="sidebarRight">1</div><br />
</div>
<img src="images/sidebar_links.gif" alt="Links" /><div class="sidebarItem"><a target="_blank" href="http://www.*****.com/">Home Site</a><br /><a target="_blank" href="http://en.wikipedia.org/wiki/Laser_tag">(Coming Soon)Laser Tag Strategies</a><br /></div>
<a href="information.php"><img class="btnL" src="images/button_info.png" alt="Statistics" border="0" /></a>
<a href="information.php?page=staff"><img class="btnL" src="images/button_staff.png" alt="Staff" border="0" /></a>

<a href="information.php?page=faq"><img class="btnL" src="images/button_faq.png" alt="FAQ" border="0" /></a>
</div>
</div>
<div class="footer"> ********* 2010. Site designed and created by Travis Neal and "blader".</div>
<div class="footerReflection"></div></div>
</div>
</body>
</html>



When "Send Mail" is pressed, this is the HTML output




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEZ - Control Panel</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
a, a:visited { color: #666666 }
a:hover { color: #999999 }
.title { color: #333333 }
.banner { background: url(images/banner_tez.png) no-repeat; }
</style></head>
<body>
<div class="container">
<div class="main">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="539" height="110" style="margin-top: -300px;">
<param name="movie" value="banner_redtez.swf" />
<param name="quality" value="best" />
<param name="menu" value="true" />
<param name="allowScriptAccess" value="always" />

<embed src="images/banner_redtez.swf" quality="best" menu="true" width="539" height="110" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always">
</embed>
</object>
<div class="navLeft"></div>
<div class="navCenter"><a href="index.php">HOME</a>
<a href="usercp.php">USER CP</a>
<a href="usercp.php?page=request">REQUEST</a>
<a href="usercp.php?page=manage">MANAGE</a>

<a href="calendar/index.php">CALENDAR</a>
<a href="usercp.php?page=logout">LOGOUT</a></div>
<div class="navRight"></div><br />
<div class="contentContainer">
<div class="navReflection"></div>
<div class="content">

<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="******" />
<input type="hidden" name="fromlast" value="******" />
<b>Debbie Solaro</b></td>
</tr>
<tr>

<td align="right" valign="top">To:</td>
<td align="left">
<input type="hidden" name="tofirst" value="*****" />
<input type="hidden" name="tolast" value="****" />
<b>Travis Neal</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>

</form> </div>

<div class="sidebar">
<img src="images/sidebar_info.gif" alt="Information" /><div class="sidebarItem">
<div class="sidebarLeft">Total Employees</div><div class="sidebarRight">2</div><br />
<div class="sidebarLeft">Total Managers</div><div class="sidebarRight">1</div><br />
</div>
<img src="images/sidebar_links.gif" alt="Links" /><div class="sidebarItem"><a target="_blank" href="http://www.q-zar.com/">Home Site</a><br /><a target="_blank" href="http://en.wikipedia.org/wiki/Laser_tag">(Coming Soon)Laser Tag Strategies</a><br /></div>

<a href="information.php"><img class="btnL" src="images/button_info.png" alt="Statistics" border="0" /></a>
<a href="information.php?page=staff"><img class="btnL" src="images/button_staff.png" alt="Staff" border="0" /></a>
<a href="information.php?page=faq"><img class="btnL" src="images/button_faq.png" alt="FAQ" border="0" /></a>
</div>
</div>
<div class="footer"> ************* 2010. Site designed and created by Travis Neal and "blader".</div>
<div class="footerReflection"></div></div>
</div>
</body>

</html>

bdl
01-17-2010, 04:06 PM
You don't have a closing FORM tag in your markup in the first form.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum