I should be able to pass variables between to HTML forms if I use the same variables on both of the pages ....correct??
My pages are:
Page 1
<?php
include_once('dbconnect.php');
// Set up query
// NOTE: Temporarily set the limit to 5 during testing.
$query = 'select id, event, DATE_FORMAT( startdate, "%M %d, %Y" ) as sd,
DATE_FORMAT( enddate, "%M %d, %Y" ) as ed, sponsor, location,
contact, comments from events where status = 0 order by startdate ';
$result = mysql_query( $query ) or die(mysql_error());
// These are the messages that get sent when a calendar item is approved or disapproved.
$message = '<p>This is a test message for approval</p>';
$message2 = '<p>This is a test for disapproval</p>';
echo '
<h1>Calendar Administration</h1>';
echo '
<table width="100%" border="1">
<tr>
<td><strong>Event</strong></td>
<td><strong>Start Date</strong></td>
<td><strong>End Date</strong></td>
<td><strong>Sponsor</strong></td>
<td><strong>Location</strong></td>
<td><strong>Contact Person</strong></td>
<td><strong>Comments</strong></td>
<td colspan="3"><strong>Status</strong></td>
</tr>
<tr>';
while ( $value = mysql_fetch_assoc( $result ))
{
// All but the last column simply display data.
echo "<td>$value[event]</td>";
echo "<td>$value[sd]</td>";
echo "<td>$value[ed]</td>";
echo "<td>$value[sponsor]</td>";
echo "<td>$value[location]</td>";
echo "<td>$value[contact]</td>";
echo "<td>$value[comments]</td>";
echo "<td>$value[status]</td>";
// Final column has the Approve / Disapprove stuff
if ( $_REQUEST['action'] == 'Approve' and (int)($_REQUEST['calendar_ID']) == $value['id'] )
{
// They hit the approve button for this row
// Send the approval email and notify user.
mail($_REQUEST['email'], $value['event'], $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
print('<td>Approval sent.</td>');
$sql = 'UPDATE events SET status = 1 WHERE ID = $_REQUEST[calendar_id] or die(mysql_error() )';
}
elseif ( $_REQUEST['action'] == 'Disapprove' and (int)($_REQUEST['calendar_ID']) == $value['id'] )
{
// They hit the disapprove button for this row
// Send the disapproval email and notify user.
mail($_REQUEST['email'], $value['event'], $message2,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
print('<td>Disapproval sent.</td>');
$sql2 = 'UPDATE events SET status = \'2\' WHERE ID = $_REQUEST[calendar_id] or die(mysql_error() )';
}
//They hit the edit button for this row
//Redirects to editevents.php for admin changes
elseif ( $_REQUEST['action'] == 'Edit Event' and (int)($_REQUEST['calendar_ID']) == $value['id'] )
{
header("Location: editevents.php");
}
else
{
// Just normal display for this row
// Display the option to approve or disapprove.
echo '
<td>
<form method="post" action="' . $_SERVER['PHP_SELF'] . '">
<input type="hidden" name="calendar_ID" value="' . $value['id'] . '" />
<input type="hidden" name="email" value="stevec@nmsu.edu" />
<input type="submit" name="action" value="Approve" />
<input type="submit" name="action" value="Disapprove" />
<input type="submit" name="action" value="Edit Event" />
</form>
</td>';
}
echo '
</tr>';
}
echo '
</table>';
echo '<a href="../index.php">Home</a> § <a href="index.php">Calendar Administration</a>';
?>
Page 2
<?php
include_once( 'dbconnect.php' );
echo'<h1>Edit Event</h1>
<form action="editevents.php" method="post">
<table>
<th align=center colspan=2>Enter your event information in the form below:</th>';
$result = mysql_query( "select *, DATE_FORMAT( startdate, '%M %d, %Y' ) as sd,
DATE_FORMAT( enddate, '%M %d, %Y' ) as ed from events where '$calendar_ID' = '$_GET[id]' " );
echo"<tr><td><b>Title:</b></td>";
echo"<td><input type=text name=startdate size=30 maxlength=30 value= '$value[title]' /></td></tr>";
echo"<tr><td><b>Start Date:</b></td>";
echo"<td><input type=text name=startdate size=30 maxlength=30 value= '$value[sd]' /></td></tr>";
echo"<tr><td><b>End Date:</b></td>";
echo"<td><input type=text name=enddate size=30 maxlength=30 value= '$value[ed]' /></td></tr>";
echo"<tr><td><b>Event:</b></td>";
echo"<td><input type=text name=event size=30 maxlength=30 value= '$value[event]' /></td></tr>";
echo"<tr><td><b>Location:</b></td>";
echo"<td><input type=text name=location size=30 maxlength=30 value= '$value[location]' /></td></tr>";
echo"<tr><td><b>Sponsor:</b></td>";
echo"<td><input type=text name=location size=30 maxlength=30 value= '$value[sponsor]' /></td></tr>";
echo"<tr><td><b>Contact Person</b></td>";
echo"<td><input type=text name=contact size=30 maxlength=30 value= '$value[contact]' /></td></tr>";
echo"<tr><td><b>Your Phone:</b></td>";
echo"<td><input type=text name=phone size=30 maxlength=30 value= '$value[phone]' /></td></tr>";
echo"<tr><td><b>Email:</b></td>";
echo"<td><input type=text name=email size=30 maxlength=30 value= '$value[email]' /></td></tr>";
echo"<tr><td><b>Submitted By:</b></td>";
echo"<td><input type=text name=submittername size=30 maxlength=30 value= '$value[submittername]' /></td></tr>";
echo"<tr><td><b>Phone:</b></td>";
echo"<td><input type=text name=submitterphone size=30 maxlength=30 value= '$value[submitterphone]' /></td></tr>";
echo"<tr><td><b>Email</b></td>";
echo"<td><input type=text name=submitteremail size=30 maxlength=30 value= '$value[submitteremail]' /></td></tr>";
echo"<tr><td><b>Comments</b></td>";
echo"<td><textarea cols=22 rows=5 name=comments value= '$value[comments]' >$value[comments]</textarea></td></tr>";
echo'<tr>
<td align="center" colspan="2">
<input type="submit" name="submit" value="Update Record" />
<input type="reset" name="action" value="Clear Form" /></td>';
echo'</tr>
</table>
</form>';
if( $_POST['submit'] )
{
$sql = mysql_query("update events set
title = '$value[title]',
startdate = '$value[sd]',
enddate = '$value[ed]',
event = '$value[event]',
location = '$value[location]',
sponsor = '$value[sponsor]',
contact = '$value[contact]',
phone = '$value[phone]',
email = '$value[email]',
submittername = '$value[submittername]',
submitterphone = '$value[submitterphone]',
submitteremail = '$value[submitteremail]',
comments = '$value[comments]'
where id = '$value[id]' ");
printf("Record updated successfully: %d\n", mysql_affected_rows() );
} else {
echo '<p><font color = "red" >Your record could not be updated. ' . mysql_error() . '<br />
We appologize for any inconvenience.<br /> Please try again</font></p>';
}
//End of Form
//Update record with new information
?>
When I am looking at the second page, I have either undefined variables or undefined indexes?
What am I overlooking??