Jump to content

Recommended Posts

I have a form that submits customer info and images to MySql.  It puts the image files on my server.  I would like to change it so it puts the image path (not the image) into MySql.  I have tried several things and can't quite get that part to work.  below is the code as it is now working.  I would appreciate any suggestions on how to tweak it to write the image path into the db.  Thank you!!


<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
mysql_select_db('mydb');



$sql="INSERT INTO Persons (FirstName, email, Age, state, nude, acting, comments, photo, photo2, photo3, photo4, photo5)
VALUES
('$_POST[firstname]', '$_POST[email]', '$_POST[age]', '$_POST[state]', '$_POST[nude]' , '$_POST[acting]' , '$_POST[comments]', '$_FILES[photo]' ,'$_FILES[photo2]' , '$_FILES[photo3]' ,'$_FILES[photo4]' ,'$_FILES[photo5]')";

if (!mysql_query($sql,$con))
  {
  die('Error: ' . mysql_error());
  }
?>  
<script language="JavaScript" type="text/JavaScript">
<!--
window.location.href = "http://www.cash4fetishmodels.com/submitted.htm";
//-->
</script>
<?php

$first_name=$_POST['firstname'];
$last_name=$_POST['lastname'];
$email=$_POST['email'];
$Age=$_POST['Age'];
$state=$_POST['state'];
$photo=$_POST['photo'];
$nude=$_POST['nude'];
$acting=$_POST['acting'];
$comments=$_POST['comments'];

$photo=($_FILES['photo']['name']);
$photo2=($_FILES['photo2']['name']);
$photo3=($_FILES['photo3']['name']);
$photo4=($_FILES['photo4']['name']);
$photo5=($_FILES['photo5']['name']);

//This is the directory where images will be saved
$target = "images/uploaded/";
$targetx = $target . basename( $_FILES['photo']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}

$targetx = $target . basename( $_FILES['photo2']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo2']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}

$targetx = $target . basename( $_FILES['photo3']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo3']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}

$targetx = $target . basename( $_FILES['photo4']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo4']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}

$targetx = $target . basename( $_FILES['photo5']['name']);

//Writes the photo to the server
if(move_uploaded_file($_FILES['photo5']['tmp_name'], $targetx))
{

//Tells you if its all ok
}
else {
//Gives and error if its not
}


$to = "[email protected]";
$from_header = "From: [email protected]";
$subject = "Model Request";
$contents = <<< emailbody
Dear Webmaster,

This person has requested more information:
First Name=$first_name
Email=$email
Age=$Age
State=$state
Photo=$photo
Nude=$nude
Acting=$acting
Comments=$comments

emailbody;
mail($to, $subject, $contents, $from_header);
mysql_close($con);
//echo header ("Location: http://cash4fetishmodels.com/submitted.htm");

?>

Sure!  And Thank you!

There is one table with a field for each:

FirstName, email, Age, state, nude, acting, comments, photo, photo2, photo3, photo4, photo5

 

The photo fields are set to mediumblob.  I have tried changing them to varchar and when I do the image upload shows as 'array' in the data field.

 

Thank you

-inebula88

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.