Hi, I've got this horribly nasty code that just won't work. It's a profile creator for a "featured band" type of situation. It's supposed to take the image, store it in a directory as well as pass the image path to mysql along with the details from the form. It uploads the image to the right directory and the textfields are entered fine, but I don't know why it's not storing the image path to mySQL. Can someone clarify things for me??
Thanks in advance!
---uploadimage.php---
. . .
<form enctype="multipart/form-data" action="add_artist.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
. . .
---add_artist.php---
. . .
<?php
$target_path = "/var/www/html/artists/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$image_path = $_FILES['uploadedfile']['name'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded<br>\n";
}
if($submit)
{//begin of if($submit).
// Set global variables
$bandname = $_POST['bandname'];
$member1 = $_POST['member1'];
$member2 = $_POST['member2'];
$member3 = $_POST['member3'];
$member4 = $_POST['member4'];
$member5 = $_POST['member5'];
$member6 = $_POST['member6'];
$member7 = $_POST['member7'];
$member8 = $_POST['member8'];
$description = $_POST['description'];
$website_url = $_POST['website_url'];
$image_path = $_POST['image_path'];
//add automatic line breaks
$description = ereg_replace(13,"<p>",$description);
$result = mysql_query("INSERT INTO artists (bandname, dtime, member1, member2, member3, member4, member5, member6, member7, member8, description, website_url, image_path)
VALUES ('$bandname',NOW(),'$member1','$member2','$member3','$member4','$member5','$member6','$member7','$member8','$description','$website_url','$image_path')",$connect);
//print success message.
echo "<b>Artist added successfully!<br>You'll be redirected to the control panel after (4) seconds, or click <a href=\"index.php\">click here</a> to go there now.\n";
echo "<meta http-equiv=Refresh content=4;url=index.php>";// yeah I know, this sucks.
}//end of if($submit).
// If the form has not been submitted, display it.
else
{//begin of else
?>
<br>
<h3>Add Artist </h3>
<form method="post" action="<?php echo $PHP_SELF ?>" enctype="multipart/form-data">
<p>Band Name:<br>
<input name="bandname" size="40" maxlength="255">
<br>
<br>
<select name="memberCount" onchange="javascript:showMembers(this.selectedIndex); this.selectedIndex = 0;">
<option>Members in band</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
<br>
<br>
<input type="text" id="member1" name="member1" style="visibility:hidden;">
<br>
<input type="text" id="member2" name="member2" style="visibility:hidden;">
<br>
<input type="text" id="member3" name="member3" style="visibility:hidden;">
<br>
<input type="text" id="member4" name="member4" style="visibility:hidden;">
<br>
<input type="text" id="member5" name="member5" style="visibility:hidden;">
<br>
<input type="text" id="member6" name="member6" style="visibility:hidden;">
<br>
<input type="text" id="member7" name="member7" style="visibility:hidden;">
<br>
<input type="text" id="member8" name="member8" style="visibility:hidden;">
<br>
<br>
Description:<br>
<textarea name="description" rows="7" cols="30"></textarea>
<br>
<br>
Website URL: (with http://) <br>
<input name="website_url" value="http://" size="40" maxlength="255">
<br>
<br>
<input type="submit" name="submit" value="Add Artist >>">
<br>
<a href="index.php"><-- Go Back</a> </p>
</p>
</form>
<?php
}//end of else
?>