
June 17th, 2003, 02:38 PM
|
|
Junior Member
|
|
Join Date: Jun 2003
Posts: 4
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Help...
Here is the code for my dilemna .. My question is below it:
PHP Code:
<?php
//start the session
session_start();
//check to make sure the session variable is registered
if(session_is_registered('username')){
//the session variable is registered, the user is allowed to see anything that follows
$db = mysql_connect("localhost", "imati0n_sess", "sess");
mysql_select_db("imati0n_sess",$db);
if ($submit) {
// here if no ID then adding else we're editing
if ($id) {
$sql = "UPDATE customers SET first='$first',last='$last',email='$email',domain= '$domain',package='$package',SubscriptionStart='$S ubscriptionStart',SubscriptionEnd='$SubscriptionEn d' WHERE id=$id";
} else {
$sql = "INSERT INTO customers (first,last,email,domain,package,SubscriptionStart ,SubscriptionEnd) VALUES ('$first','$last','$email','$domain','$package','$ SubscriptionStart','$SubscriptionEnd')";
}
// run SQL against the DB
$result = mysql_query($sql);
echo "Record updated/edited!<p>";
} elseif ($delete) {
// delete a record
$sql = "DELETE FROM customers WHERE id=$id";
$result = mysql_query($sql);
echo "$sql Record deleted!<p>";
} else {
// this part happens if we don't press submit
if (!$id) {
// print the list if there is not editing
$result = mysql_query("SELECT * FROM customers",$db);
while ($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?id=%s\">%s %s</a> \n", $PHP_SELF, $myrow["id"], $myrow["first"], $myrow["last"]);
printf("<a href=\"%s?id=%s&delete=yes\">(DELETE)</a><br>", $PHP_SELF, $myrow["id"]);
}
}
echo(" <P>
<a href='checkLogin.php'>ADD A RECORD</a>
<P>
<form method='POST' action='checkLogin.php'> ");
if ($id) {
// editing so select a record
$sql = "SELECT * FROM customers WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["id"];
$first = $myrow["first"];
$last = $myrow["last"];
$email = $myrow["email"];
$domain = $myrow["domain"];
$package = $myrow["package"];
$SubscriptionStart = $myrow["SubscriptionStart"];
$SubscriptionEnd = $myrow["SubscriptionEnd"];
// print the id for editing
echo('
<input type=hidden name="id" value="<?php echo $id ?>">
');
}
echo('
First name:<input type="Text" name="first" value="$first"><br>
Last name:<input type="Text" name="last" value="$last"><br>
Email Adress:<input type="Text" name="emailaddress" value="$email"><br>
Domain Name:<input type="Text" name="domainname" value="$domain"><br>
Package:<input tpe="Text" name="package" value="$package"><br>
Subscription Start:<input tpe="Text" name="SubscriptionStart" value="$SubscriptionStart"><br>
Subscription End:<input tpe="Text" name="SubscriptionEnd" value="$SubscriptionEnd"><br>
<input type="Submit" name="submit" value="Enter information">
</form> ');
}
}
else{
//the session variable isn't registered, send them back to the login page
header( "Location: http://www.liquidfridge.net/admin/index.php" );
}
?>
What happens is that when the form is shown (To add/edit entries) it doesn't show the information previously entered into the form for that specific record. Here is a screen shot
URL
If anyone can help me I would praise you like an adonis...
Best Regards,
Kyle Foxon
|