Thank you for the reply!! As I have said, I am a Newbie, so be gentle 😉
The code for this page is below. What do I need to change to make this work right.
<?php
// +----------------------------------------------------------------------+
// | profile_update.php |
// | This file updates db with student profile. |
// +----------------------------------------------------------------------+
include("../inc/timer.php");
include_once("../config.php");
include_once("../inc/version.php");
include_once("./inc/functions.php");
checkLoggedIn("yes");
include("./inc/userinfo.php");
include("../inc/dtd.php");
?>
<title>Online Portfolios</title>
<!-- Start Stylesheet Block -->
<?php include("../inc/styles.php");?>
<!-- End Stylesheet Block -->
</head>
<body>
<div id="container">
<!-- Start Banner Block -->
<?php include("../inc/banner.php");?>
<!-- End Banner Block -->
<div id="sidebar-a">
<!-- Start Find Portfolio Block -->
<?php include("./inc/nav.php");?>
<!-- End Find Portfolio Block -->
</div>
<!-- Start Content Block -->
<div id="content">
<h3>Update your profile</h3>
<?php
# if magic quotes not set, add slashes
if (!get_magic_quotes_gpc()) {
$profiletext = addslashes($profiletext);
}
$sql = "SELECT profiletext, userid FROM profile WHERE userid='{$user["userid"]}'";
$page_count = mysql_query($sql,$db);
# If does not exist in the database, insert a new entry
if (!mysql_num_rows($page_count)) {
$sql = "INSERT INTO profile (userid, profiletext, imgname) VALUES('{$user["userid"]}', '$profiletext', NULL)";
$result = mysql_query($sql,$db);
}
// file upload fix from Pete Shima
if(!empty($file_name)){
$img=explode(".",$file_name);
$upldfile="{$user["userid"]}.$file_name";
$fileext = substr($file_name, -3);
if(($fileext != "gif") && ($fileext != "jpg")){
echo "<p><b>$file_name</b> name is not a valid image.<br /><br />
Please make sure your file is one of the following types: <br /> <br />
* GIF Image<br />
* JPG Image<br /><br />
Please click the back button and change your file, thank you.</p>";
die;
}
// if file exists, delete it
if (file_exists("$filepath$upldfile"))
{unlink("$filepath$upldfile");}
// upload file and insert profile into database
if(copy($file,"$filepath$file_name")){
if(rename("$filepath$file_name","$filepath$upldfile")){
$foo=false;
$query="UPDATE profile SET profiletext='$profiletext',imgname='$upldfile' WHERE userid='{$user["userid"]}'";
$db=mysql_query($query,$db);
echo "<b>Image upload and profile update complete</b><br>";
} // rename
}
} else{}
?>
</div>
<!-- end content block -->
<!-- Start Footer Block -->
<?php include("../inc/footer.php");?>
<!-- End Footer Block -->
</div>
<!-- Start Klahowya Info Block -->
<?php include("../inc/powered.php");?>
<!-- End Klahowya Info Block -->
</body>
</html>
<!-- The End -->
Thank you in advance. I'm trying to teach myself new tricks, but it isn't working very well 😉
Marc