Re: Image / file uploader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sure - I never thought i would have some many issues with a "simple" postback. ;)

Here 's the code:
<?
function display_edit_bio($user_id)
{
if($_POST['postback_bio'])
{

include "include/dbadmin.php";

//image uploader
$uploadpath = 'images/clients/';

$source = $HTTP_POST_FILES['photo']['tmp_name'];
$photo_name = $HTTP_POST_FILES['photo']['name'];
$dest = '';
if (($source != '') && ($source != '')) {
$dest = $uploadpath.$photo_name;
if ($dest != '') {
if (move_uploaded_file($source, $dest)) {
echo ("<p id='message'>Image and Bio has been successfully stored.</p> ");
} else {
echo ("<p id='message'>Image could not be stored.</p>");
}
}
} else {
echo ("<p id='message'>No new image supplied.</p>");
$photo_name = $oldimage;
}

//declare varibles
$user_id = $_POST["user_id"];
$name = $_POST["name"];
$bio = $_POST["bio"];
$goals = $_POST["goals"];
$fav_race = $_POST["fav_race"];
$fav_train = $_POST["fav_train"];
$photo = $_POST["photo_name"];

$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race = '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name' WHERE user_id = '$user_id'";
echo $query;
$msg = "<span style='color:red' id='message'>Could not update record</span>";
$result = mysql_query($query, $db) or ($msg);


}

?>
______________________________________
Craig Hoffman
iChat: m0untaind0g
______________________________________
On Apr 30, 2004, at 9:17 AM, Hutchins, Richard wrote:

Craig,

Where is the code that actually handles the image upload? Is it in
/~choffman/www/mtrain/client_profile.php? If so, can you post that too?

Rich

-----Original Message-----
From: Craig Hoffman [mailto:choffman@xxxxxxxxxxx]
Sent: Friday, April 30, 2004 10:08 AM
To: Hans Lellelid
Cc: php-db@xxxxxxxxxxxxx
Subject: Re:  Image / file uploader


No problem - Here you go. Thanks - CH


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">
<head>
	<title>eClimb Media and RaceLogix Traininglog</title>
	<meta name="generator" content="BBEdit 7.1.3" />
	<meta name="author" content="eClimb Media -
www.eclimbmedia.com" />
	<meta name="copyright" content="eClimb Media -
www.eclimbmedia.com" />
	<meta name="description" content="online personal
traininglog brought
to you by eClimb Media and RaceLogix" />
	<meta name="keywords" content="personal training,
marathon training
program, racelogix, eclimb media, running, traininglog, training" />
</head>
<link rel="stylesheet" rev="stylesheet" href="css/standard.css"
media="all" />
<body>

<table width="700" border="0" cellspacing="0" cellpadding="0"
align="center" id="main_content_table">
	<tr>
		<td colspan="4" id="content_header"><h2>Welcome
to Training
log</h2></td>
	</tr>
	<tr valign="top">
		<td width="100" id="content_table_nav"><table
id="left_nav_table"
cellpadding="0" cellspacing="0">
	<tr>
		<td width="100" height="22" id="home"><a
href="index.php">Home</a></td>
	</tr>
</table>

<br />

<table id="left_nav_table"cellpadding="0" cellspacing="0" >	
	<tr>	
		<td width="100" height="22" id="coaching"><a
href="login.php">Login</a></td>
	</tr>
	<tr>	
		<td width="100" height="22" id="mailing"><a
href="mailinglist.php">Mailing List</a></td>
	</tr>	
	<tr>	
		<td width="100" height="22" id="contact"><a
href="contact.php">Contact</a></td>
	</tr>
	

</table>

<br />

<table id="left_nav_table" cellpadding="0" cellspacing="0">
	<tr>	
		<td width="125" height="22" id="coaching"><a
href="coaching.php">Coaching</a></td>
	</tr>
	<tr>	
		<td width="125" height="22" id="Group Run"><a
href="grouprun.php">Group Runs</a></td>
	</tr>	
	<tr>	
		<td width="125" height="22" id="Group Run"><a
href="featuredathlete.php">Featured Athlete</a></td>
	</tr>
</table>

<br />

<table id="left_nav_table"cellpadding="0" cellspacing="0">	
	<tr>	
		<td width="100" height="22" id="utilities"><a
href="util.php">Utilities</a></td>
	</tr>
	<tr>	
		<td width="100" height="22" id="logout"><a
href="logout.php">Logout</a></td>
	</tr>	
	
	
</table></td>
		<td id="content_cell" width="500"><h4>Edit Your Bio</h4>
		<h2>Tell us a little about yourself.</h2>
		
  <p id='message'>No new image supplied.</p>

UPDATE users SET bio = 'Hello World - Bio', goals = 'Hello World -
Goal', fav_race = 'Hello World - Race', fav_train = 'Hello World -
Trainingf', photo_name = ''  WHERE user_id = '12'

<form method='post' action='/~choffman/www/mtrain/client_profile.php'
encType='multipart/form-data'><table border='0' cellpadding='5'
width='500' cellspacing='0' id='result_table'>
						<tr bgcolor='#DBE6D1'>
								
<td width='100'><b>Name:<b></td>
								
<td>Craig Hoffman</td></tr><tr><tr bgcolor='#ECF8DF'>
								
<td><b>Bio:</b></td>
								
<td colspan='2'><textarea rows='4'name='bio' cols='45'>Hello
World - Bioing</textarea></td>
							</tr>	
							
							<tr
bgcolor='#DBE6D1'>
								
<td><b>Goals:</b></td>
								
<td colspan='2'><textarea rows='4' name='goals' cols='45'>Hello
World - Goaling</textarea></td>
							</tr>	
							
							<tr
bgcolor='#ECF8DF'>
								
<td><b>Favorite Race:</b></td>
								
<td colspan='2'><textarea rows='4' name='fav_race'
cols='45'>Hello World - Raceing</textarea></td>
							</tr>
							
							<tr
bgcolor='#DBE6D1'>
								
<td><b>Favorite Place to Train:</b></td>
								
<td colspan='2'><textarea rows='4' name='fav_train'
cols='45'>Hello World - Trainingfsdf</textarea></td>
							</tr>
							
							<tr
bgcolor='#ECF8DF'>
								
<td ><b>Upload Photo:</b></td>
								
<td colspan='2'><input type='file' name='photo'>
							</tr>
							
							<tr
bgcolor='#DBE6D1'>
								
<td colspan='3'>
								
<INPUT type='hidden' name='MAX_FILE_SIZE' value='10000000'>
								
<input type='hidden' name='oldimage' value=''>
								
<input type='hidden' name='user_id' value='12'>
								
<input type='hidden' name='postback_bio' value='true'>
								
<input type='submit' value='Submit' id='submit_buttom'></td>	
							</tr>
					</table>
					</form>		
		
		
		</td>
	</tr>
</table>
</body>
</html>

__________________________________
Craig Hoffman - eClimb Media

v: (847) 644 - 8914
f: (847) 866 - 1946
e: choffman@xxxxxxxxxxxxxxx
w: www.eclimbmedia.com
_________________________________
On Apr 30, 2004, at 8:56 AM, Hans Lellelid wrote:

Here you go: I mostly echo out the HTML. I have included the
entire
form here.
Thanks - CH

echo ("<form method='post'
action='{$_SERVER['PHP_SELF']}'
encType='multipart/form-data'>");
            echo ("<table border='0' cellpadding='5' width='500'
...

If you could send the actual resulting HTML that is echoed by your script, that would be more helpful in diagnosing why your browser isn't posting back to the right page.

HL

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux