here is the code i am using for all of three pages incase it is any one of them.
first the search one
Code:
<?php
require('link.php');
// If search is active
if ($_POST['search']) {
$date = $_POST['LName'];
// Get results from database
$users = mysql_query("SELECT * FROM `form` WHERE LName = '$date' ORDER BY RegID DESC") or die ('Error Getting Users! \n<br />\n' .mysql_error());
$chk = mysql_num_rows($users);
// If no users found
if ($chk < 1) {
echo 'There are no users registered on the date: <b>'.$date.'</b>
<br />
<a href="bih.html"><<Back</a>';
}
// If there are users
// If there are users
else {
// Start table to display users
echo '
<h3>Users Registerd With Last Name of '.$date.'</h3>
<table border="1">
<tr>
<td></td><td></td>
<td><b>First Name</b></td>
<td><b>Last Name</b></td>
<td><b>Date Attending</b></td>
<td><b>Email</b></td>
<td><b>Phone Number</b></td>
</tr>';
// For each user found
while($u = mysql_fetch_array($users)) {
// Show data for each user
echo '
<tr>
<td><a href="edit.php?RegID='.$u['RegID'].'">Edit</a></td>
<td><a href="delete.php?act=chk_del&id='.$qry['RegID'].'">Delete</a></td>
<td>'.$u['RegID'].'</td>
<td>'.$u['FName'].'</td>
<td>'.$u['LName'].'</td>
<td>'.$u['Date'].'</td>
<td>'.$u['EMail'].'</td>
<td>'.$u['Phone'].'</td>
</tr>';
}
// End table
echo '
</table><br><br><a href="bih.html">Back</a>';
}
}
// If form was not submitted
if (!$_POST['search']) {
echo '
<form method="post" action="">
<b>Last Name:</b> <input type="text" name="LName" />
<input type="submit" name="search" value="Search" />
</form><br><br><a href="bih.html">Back</a>';
}
if ($_GET['act'] == 'edit') {
require('edit.php');
}
?>
next the edit one:
Code:
<?php
require('link.php');
// Get the user id
$RegID = $_GET['RegID'];
// Get data from user with the specified id
$info = mysql_query("SELECT * FROM `form` WHERE RegID = '$RegID'") or die ('Error Getting User Data! <br />' .mysql_error());
$chk = mysql_num_rows($info);
$u = mysql_fetch_array($info);
// If edit not hit
if (!$_POST['edit']) {
// If user id returns no results
if ($chk < 1) {
echo 'The user with the id <b>'.$RegID.'</b> does not exist!';
}
else {
// Edit Form
?>
<!-- Edit Form -->
<form method="post" action="">
<table width="250">
<tr>
<td>First Name:</td>
<td><input type="text" name="firstname" value="<?php echo $u['FName'] ?>" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="lastname" value="<?php echo $u['LName'] ?>" /></td>
</tr>
<tr>
<td>Username:</td>
<td><input type="text" name="EMail" value="<?php echo $u['EMail'] ?>" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="edit" value="Edit" /></td>
</tr>
</table>
</form>
<!-- /Edit Form -->
<?
}
// If edit was hit
if ($_POST['edit']) {
$firstname = $_POST['FName'];
$lastname = $_POST['LName'];
$username = $_POST['EMail'];
// Update data
$update = mysql_query("UPDATE `form` SET FName = '$FName', LName = '$LName', EMail = '$EMail' WHERE RegID = '$RegID'") or die ('Error Updating Data! <br />' .mysql_error());
echo 'Update successfull
<br />
<a href="bih.html">Back To Main</a>';
}
}
?>
last the delete one:
Code:
<?php
require('link.php');
// If delete was hit, ask for confirm
if ($_GET['act'] == 'chk_del') {
$RegID = $_GET['RegID'];
echo 'Are you sure you want to delete this user?
<br />
<a href="delete.php?act=delete&RegID='.$RegID.'">Yes, delete it</a> | <a href="javascript:history.back();">Cancel</a>';
}
// If delete confirmed
elseif ($_GET['act'] == 'delete') {
$RegID = $_GET['RegID'];
$del = mysql_query("DELETE FROM `form` WHERE RegID ='$RegID'") or die ('Error Deleting User! <br />' .mysql_error());
echo 'The user has been deleted.
<br />
<a href="bih.html">Back To Main</a>';
}
?>
man sorry for all the trouble i am causing you. i really appreciate the help though.
Bookmarks