hello all.... i have a few problems with my code that i made
first of all.... it shows everyone's list of profiles to be deleted on everyone's member page, not just there own like ti should be...
2nd.... it doesnt' update teh database, instead it will go in and actually make a new id with the info entered into the form...
3rd..... a few of the fileds do not show up in the mysql database, and i don't know why.. this would include the engine part...
my database layout is like
id- int(11) auto_increment not null(seems to work, it started at 1 and goes up by 1 at a time.... but it's adding a new profile when the form is submitted as stated above)
login-varchar(25) not null
password-varchar(15) not null
fname-varchar(15) not null
year -varchar(5) not null
color-varchar(15) not null
model-varchar(25) not null
engine-varchar(5) not null
interiormods-text not null
exteriormods-text not null
suspensionmods-text not null
performancemods-text not null
factorymods-text not null
<?php
/*************************************************************************
|script by Mike Filtenborg for dv6cougar.com's profile management. Feel |
|free to use this as you please but a link to my site would be greatly |
|appreciated. Url= [url]http://www.dv6cougar.com.[/url] Thank you and enjoy :) |
*************************************************************************/
include_once("config.php");
checkLoggedIn("yes");
doCSS();
print("Welcome to your profile <b>".$_SESSION["session"]["login"]."</b><br>");
print("<font size=\"5\"><a href=\"logout.php?".session_name()."=".session_id()."\">Logout</a></font><br>");
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="main.css">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
$login = $_SESSION["session"]["login"];
$db = mysql_connect("localhost","$user","$pw");
//line 25
mysql_select_db("$database",$db);
if($submit) {
if($login) {
$sql = "UPDATE users SET fname='$fname',
year='$year',
color='$color',
model='$model',
engine='$engine',
interiormods='$interiormods',
exteriormods='$exteriormods',
suspensionmods='$suspensionmods',
performancemods='$performancemods',
factorymods='$factorymods'
WHERE login=$login";
}
else
{
$sql = "INSERT INTO users (fname,
year,
color,
model,
engine,
interiormods,
exteriormods,
suspensionmods,
performancemods,
factorymods) VALUES ('$fname',
'$year',
'$color',
'$model',
'$engine',
'$interiormods',
'$exteriormods',
'$suspensionmods',
'$performancemods',
'$factorymods')";
}//line 64
$result = mysql_query($sql);
echo "Your profile has been edited<p>";
}
elseif ($delete) {
$sql = "DELETE FROM users WHERE login=$login";
$result = mysql_query($sql);
echo "$sql profile deleted!<p>";
//line 73
}
else
{
if(!$login) {
$result = mysql_query("SELECT * FROM users",$db);
while($myrow = mysql_fetch_array($result)) {
printf("<a href=\"%s?login=%s\">%s %s</a> \n", $PHP_SELF,$myrow["login"],
$myrow["year"],
$myrow["color"],
$myrow["model"],
$myrow["engine"],
$myrow["interiormods"],
$myrow["exteriormods"],
$myrow["suspensionmods"],
$myrow["performancemods"],
$myrow["factorymods"]);
printf("<a href=\"%s?login=%s&delete=yes\">(DELETE)</a><br>", $PHP_SELF, $myrow["login"]);
}
}
?>
<p>
<a href="<?php echo $PHP_SELF?>">ADD A RECORD</a>
<p>
<form method="post" actions="<?php echo $PHP_SELF?>">
<?php
if($username){
$sql = "SELECT * FROM users WHERE login=$login";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
$id = $myrow["login"];
$year = $myrow["year"];
$color = $myrow["color"];
$model = $myrow["model"];
$engine = $myrow["engine"];
$interiormods = $myrow["interiormods"];
$exteriormods = $myrow["exteriormods"];
$suspensionmods = $myrow["suspensionmods"];
$performancemods = $myrow["performancemods"];
$factorymods = $myrow["factorymods"];
?>
<input type="hidden" name="login" value="<?php echo $id ?>">
<?php
}
?>
First Name:<input type="text" name="fname" value="<?php echo $fname ?>"><br>
Cougar Year:<input type="text" name="year" value="<?php echo $year ?>"><br>
Color:<input type="text" name="color" value="<?php echo $color ?>"><br>
Model:<select name="model" value="<?php echo $model ?>">
<option selected value="Non-Convenience">Non-Convenience</option>
<option value="Convenience Package">Convenience Package</option>
<option value="C2">C2</option>
<option value="XR">XR</option>
<option value="35th Anniversary">35th Anniversary</option>
</select><br>
Engine:<select name"engine" value="<?php echo $engine ?>">
<option selected value="V6">V6</option>
<option value="Inline 4">Inline 4</option>
</select><br>
Interior Mods:<textarea name="interiormods" cols="26" rows="2" WRAP value="<?php echo $interiormods ?>"></textarea><br>
Exterior Mods: <textarea name="exteriormods" cols="26" rows="2" WRAP value="<?php echo $exteriormods ?>"></textarea><br>
Suspension Mods:<textarea name="suspensionmods" cols="26" rows="2" WRAP value="<?php echo $suspensionmods ?>"></textarea><br>
Performance Mods:<textarea name="performancemods" cols="26" rows="2" WRAP value="<?php echo $performancemods ?>"></textarea><br>
Factory Mods:<textarea name="factorymods" cols="26" rows="2" WRAP value="<?php echo $factorymods ?>"></textarea><br>
<input type="submit" name="submit" value="Enter Information">
</form>
<?php
}
?>
</body>
</html>
my first attempt i did the id in place of all the login's and i changed it to username... nothing seems to work right
any help woudl be greatly appreciated 🙂
thanks