Advertisement

11.26.2007 at 01:58PM PST, ID: 22983669
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.4

PHP upload and display profile image

Asked by lstraw in PHP Scripting Language

Tags: , ,

Hello.  First off, i'm a beginner to PHP, but I'm getting into it, and would appreciate a little help. Here's what I want to do.  I've got a webpage that has user profile information, and it is pretty much finished except for the fact that I want to allow the user to add a picture of themselves in their profile page.  I have 2 documents, one that is the main page, called My_Files.php, and it is used for uploading the files.  It works fine for uploading the information to my webserver, however, once there, I need for the image to be stored inside the user's profile independently, so if that requires that I also store the image inside of my mysql table, called USER, then that is fine.  This document looks like the following:
<<<<<My_Files.php>>>>>>

<html>
<head>
<title>My Files</title>
<link rel="Stylesheet" type="text/css" href="CS170/Stylesheet2.css">
</head>
<body>
<form enctype="multipart/form-data" action="b.php" method="POST">
      <table border="0" height="96%" width="89%" id="table1">
            <tr>
                  <td width="65%">                  
<?php  
$email = $_POST['email'];
$username = $_POST['username'];  
$plaintext = $_POST['password'];  
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$profileimage = $_POST['profileimage'];
$education_level = $_POST['education_level'];
$company = $_POST['company'];
$jobtitle = $_POST['jobtitle'];
$street = $_POST['street'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$birthday = $_POST['birthday'];
$website = $_POST['website'];
$phone = $_POST['phone'];
$aboutme = $_POST['aboutme'];
$resume = $_POST['resume'];
$ciphertext = md5($plaintext);
$rv = mysql_connect("localhost","USERNAME","PASSWORD");  
mysql_select_db("DATABASENAME");  
$qs = "select * from USER where username='$username';";  
$result = mysql_query($qs);  
$nrows = mysql_numrows($result);
$query = mysql_query($qs);
while ($row = mysql_fetch_array($query))  
if($nrows == 1)
{    
$dbpass = mysql_result($result, 0, "password");            
{
}  
$dbpass = mysql_result($result, 0, "password");    
$dbpass = mysql_result($result, 0, "password");    
if($dbpass == $ciphertext)
{      
echo "<h1> " ."Welcome " . $username . "!" . "</h1> " . "\n";
printf("<img border='0' src='Images\Profiles\NoImage.gif'>\n");
printf("<input type='hidden' name='MAX_FILE_SIZE' value='100000'>\n");
echo "<h2>" . "Upload a Profile Picture: " . "</h2>" . "\n";
printf("<input name='file' type='file'>\n");
printf("<input type='submit' value='Add Picture'>\n");
echo "<br>" . "\n";
echo "<br>" . "\n";
echo "<h2> " ,$row['fname'] ." " . $row['lname'] . "<br> " .  "Email: " ,$row['email'] . "</h2> " . "\n";
echo "<h3> " ."Other Information";  
echo "<h4> " ."Name: " .$row['fname'] ." " . $row['lname'] . "<br> " .  "Education Level: " .$row['education_level'] . "<br> " .  "Current Employer: " .$row['company'] . "<br> " .  "Job Title: " .$row['jobtitle']. "<br> " .  "Address: " .$row['street'] . "<br> " .  "City: " .$row['city'] . "<br> " .  "State: " .$row['state'] . "<br> " .  "Zip Code: " .$row['zip'] . "<br> " .  "Birthday: " .$row['birthday'] . "<br> " .  "Website: " .$row['website'] . "<br> " .  "Phone Number: " .$row['phone'] . "</h4> " . "\n";  
echo "<h3> " ."My Background " . "</h3> " . "\n";
echo "<h4> " .$row['aboutme'] . "</h4> " . "\n";
echo "<h3> " . "Skills" . "</h3>" . "<br> " . "<h4> " .$row['resume'] . "</h4>" . "\n";
printf("<input type='hidden' name='email' value='$email'>\n");    
printf("<input type='hidden' name='username' value='$name'>\n");    
printf("<input type='hidden' name='password' value='$ciphertext'>\n");
printf("<input type='hidden' name='fname' value='$fname'>\n");
printf("<input type='hidden' name='lname' value='$lname'>\n");            
printf("</form>\n");  
}
else
{      
printf("<h1>Password incorrect.</h1><br><br><br><br><br><br>\n");    
}  
}
else
{    
printf("<h1>Invalid name: %s</h1>\n",$username);  
}  
mysql_close();
?>
<td width="40%"></td>      
</tr>
</form>
</table>
</body>
</html>

While b.php is the document that processes when they attempt to upload the information.  It looks as follows:

<<<<<<<<b.php>>>>>>>>

<?php
 $username = $_POST['username'];
 $profileimage = $_POST['profileimage'];
 mysql_connect("localhost","USERNAME","PASSWORD");  
 mysql_select_db("DATABASE");
if (($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg")
&& ($_FILES["file"]["size"] < 100000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br />";
    echo "Type: " . $_FILES["file"]["type"] . "<br />";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    if (file_exists("FILEPATHNAMECHANGED" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "/FILEPATHNAMECHANGED" . $_FILES["file"]["name"]);
      }
    }
  }
else
  {
  echo "Invalid file";
  }
?>

My question is, how would I use this to display the image that is uploaded onto My_Files.php when it is next loaded?  If I need to use a sql statement to pull info that's fine, but I'm a little lost.  Help please!!!Start Free Trial
[+][-]11.26.2007 at 03:11PM PST, ID: 20354100

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 03:52PM PST, ID: 20354313

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 04:30PM PST, ID: 20354470

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 05:23PM PST, ID: 20354705

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP Scripting Language
Tags: display, php, upload
Sign Up Now!
Solution Provided By: wildzero
Participating Experts: 1
Solution Grade: A
 
 
[+][-]11.26.2007 at 05:24PM PST, ID: 20354708

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 05:35PM PST, ID: 20354745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 06:06PM PST, ID: 20354849

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.26.2007 at 06:08PM PST, ID: 20354860

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 03:17AM PST, ID: 20356977

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 03:18AM PST, ID: 20356984

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 03:38AM PST, ID: 20357066

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 03:40AM PST, ID: 20357075

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 04:53AM PST, ID: 20357416

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 05:12AM PST, ID: 20357525

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 11:53AM PST, ID: 20360754

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 12:29PM PST, ID: 20361036

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 12:32PM PST, ID: 20361065

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 12:49PM PST, ID: 20361201

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 01:24PM PST, ID: 20361446

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 01:50PM PST, ID: 20361604

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 05:44PM PST, ID: 20362650

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 06:02PM PST, ID: 20362713

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.27.2007 at 06:04PM PST, ID: 20362719

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628