dhtseany
July 1st, 2009, 10:59 PM
Hi guys,
What I'm trying to do is use an HTML based form for edit information already stored in a MySQL database. So far, I've successfully called the information from the database but now I'm kinda lost on how to actually update it.
Here is my current, working code:
<?
$eid = $_GET["eid"];
session_start();
if (!isset($_SESSION['username'])) {
echo "<meta http-equiv='refresh' content='0;URL=http://www.131blacksheep.com/secure/login.php' />";
echo "Please log in...";
} elseif (!isset($_SESSION['priv']) OR $_SESSION['priv'] != '1') {
echo "You are not authorized to view this page. Please wait.";
echo "<meta http-equiv=refresh content=2;URL=http://www.131blacksheep.com/secure/members.php />";
} else {
// Begin Secured Page //
include('dbconnect.php');
include('../include/1.php');
echo "<p><h2><a href='http://www.131blacksheep.com/secure/admin.php'>Admin CPanel</a> > <a href='http://www.131blacksheep.com/secure/admin_eventsmgt.php'>Events Management</a> > Event Details</h2><br></p>";
$
$result = mysql_query("SELECT * FROM events WHERE eid='".$eid."' ORDER BY edate ASC");
while($row = mysql_fetch_assoc($result)){
$edate = $row["edate"];
$etitle = $row["etitle"];
$etimes = $row["etimes"];
$etimee = $row["etimee"];
$eaddmq = $row["eaddmq"];
$eadd1 = $row["eadd1"];
$eadd2 = $row["eadd2"];
$ecitst = $row["ecitst"];
$eaddzip = $row["eaddzip"];
$euod = $row["euod"];
$edet = $row["edet"];
$ecaptrans = $row["ecaptrans"];
echo "
<table width='75%'>
<form action='admin_eventedit.php' method='post' name='main'>
<tr><td>Date:</td><td><input type='text' name='edate' size='35' value='".$edate."' />
<A HREF=\"#\"
onClick=\"cal.select(document.forms['main'].edate,'anchor1','MM/dd/yyyy'); return false;\"
NAME=\"anchor1\" ID=\"anchor1\"><img src='http://www.131blacksheep.com/img/calendar.jpg' width='30px' height='30px' alt='Select Date'></A>
</td></tr>
<tr><td>Title:</td><td><input type='text' name='etitle' size='35' value='".$etitle."'/></td></tr>
<tr><td>Start Time:</td><td><input type='text' name='etimes' size='35' value='".$etimes."'/></td></tr>
<tr><td>End Time:</td><td><input type='text' name='etimee' size='35' value='".$etimee."'/></td></tr>
<tr><td>Mapquest URL:</td><td><input type='text' name='eaddmq' size='35' value='".$eaddmq."'/></td></tr>
<tr><td>Address 1:</td> <td><input type='text' name='eadd1' size='35' value='".$eadd1."'/></td></tr>
<tr><td>Address 2:</td><td><input type='text' name='eadd2' size='35' value='".$eadd2."'/></td></tr>
<tr><td>City, State:</td><td><input type='text' name='ecitst' size='35' value='".$ecitst."'/></td></tr>
<tr><td>Zip:</td><td><input type='text' name='eaddzip' size='35' value='".$eaddzip."'/></td></tr>
<tr><td>UOD:</td><td>
<select name='euod'>
<option value='Civies'>Civies</option>
<option value='BDU'>BDU</option>
<option value='PT'>PT</option>
<option value='SA'>Summer A's</option>
<option value='SB'>Summer B's</option>
<option value='WA'>Winter A's</option>
<option value='WB'>Winter B's</option>
</select></td></tr>
<tr><td>Details:</td><td>
<textarea rows='5' cols='30' name='edet' wrap='physical'>".$edet."</textarea>
</td></tr>
<tr><td>CAP Trans Availabe?</td><td>
<input type='radio' name='ecaptrans' value='Yes' /> Yes
<input type='radio' name='ecaptrans' value='No' checked='checked' /> No</td></tr>
<tr><td><input type='submit' value='Update'></td></tr>
</table>
</form>";
}
include('../include/2.php');
// End Secured Page //
}
?>
Where would I go from here? I'm sure somewhere I'll need a MySQL query to update the records but how would I only allow one MySQL to work vs. the other present?
If I'm not making sense, let me know and I'll explain further.
Thanks,
Sean
What I'm trying to do is use an HTML based form for edit information already stored in a MySQL database. So far, I've successfully called the information from the database but now I'm kinda lost on how to actually update it.
Here is my current, working code:
<?
$eid = $_GET["eid"];
session_start();
if (!isset($_SESSION['username'])) {
echo "<meta http-equiv='refresh' content='0;URL=http://www.131blacksheep.com/secure/login.php' />";
echo "Please log in...";
} elseif (!isset($_SESSION['priv']) OR $_SESSION['priv'] != '1') {
echo "You are not authorized to view this page. Please wait.";
echo "<meta http-equiv=refresh content=2;URL=http://www.131blacksheep.com/secure/members.php />";
} else {
// Begin Secured Page //
include('dbconnect.php');
include('../include/1.php');
echo "<p><h2><a href='http://www.131blacksheep.com/secure/admin.php'>Admin CPanel</a> > <a href='http://www.131blacksheep.com/secure/admin_eventsmgt.php'>Events Management</a> > Event Details</h2><br></p>";
$
$result = mysql_query("SELECT * FROM events WHERE eid='".$eid."' ORDER BY edate ASC");
while($row = mysql_fetch_assoc($result)){
$edate = $row["edate"];
$etitle = $row["etitle"];
$etimes = $row["etimes"];
$etimee = $row["etimee"];
$eaddmq = $row["eaddmq"];
$eadd1 = $row["eadd1"];
$eadd2 = $row["eadd2"];
$ecitst = $row["ecitst"];
$eaddzip = $row["eaddzip"];
$euod = $row["euod"];
$edet = $row["edet"];
$ecaptrans = $row["ecaptrans"];
echo "
<table width='75%'>
<form action='admin_eventedit.php' method='post' name='main'>
<tr><td>Date:</td><td><input type='text' name='edate' size='35' value='".$edate."' />
<A HREF=\"#\"
onClick=\"cal.select(document.forms['main'].edate,'anchor1','MM/dd/yyyy'); return false;\"
NAME=\"anchor1\" ID=\"anchor1\"><img src='http://www.131blacksheep.com/img/calendar.jpg' width='30px' height='30px' alt='Select Date'></A>
</td></tr>
<tr><td>Title:</td><td><input type='text' name='etitle' size='35' value='".$etitle."'/></td></tr>
<tr><td>Start Time:</td><td><input type='text' name='etimes' size='35' value='".$etimes."'/></td></tr>
<tr><td>End Time:</td><td><input type='text' name='etimee' size='35' value='".$etimee."'/></td></tr>
<tr><td>Mapquest URL:</td><td><input type='text' name='eaddmq' size='35' value='".$eaddmq."'/></td></tr>
<tr><td>Address 1:</td> <td><input type='text' name='eadd1' size='35' value='".$eadd1."'/></td></tr>
<tr><td>Address 2:</td><td><input type='text' name='eadd2' size='35' value='".$eadd2."'/></td></tr>
<tr><td>City, State:</td><td><input type='text' name='ecitst' size='35' value='".$ecitst."'/></td></tr>
<tr><td>Zip:</td><td><input type='text' name='eaddzip' size='35' value='".$eaddzip."'/></td></tr>
<tr><td>UOD:</td><td>
<select name='euod'>
<option value='Civies'>Civies</option>
<option value='BDU'>BDU</option>
<option value='PT'>PT</option>
<option value='SA'>Summer A's</option>
<option value='SB'>Summer B's</option>
<option value='WA'>Winter A's</option>
<option value='WB'>Winter B's</option>
</select></td></tr>
<tr><td>Details:</td><td>
<textarea rows='5' cols='30' name='edet' wrap='physical'>".$edet."</textarea>
</td></tr>
<tr><td>CAP Trans Availabe?</td><td>
<input type='radio' name='ecaptrans' value='Yes' /> Yes
<input type='radio' name='ecaptrans' value='No' checked='checked' /> No</td></tr>
<tr><td><input type='submit' value='Update'></td></tr>
</table>
</form>";
}
include('../include/2.php');
// End Secured Page //
}
?>
Where would I go from here? I'm sure somewhere I'll need a MySQL query to update the records but how would I only allow one MySQL to work vs. the other present?
If I'm not making sense, let me know and I'll explain further.
Thanks,
Sean