Jump to content

Never did this before, so seeking FORM / Uploading Images help ...


spacepoet

Recommended Posts

Hello:

 

I would like to know how I can add the option to upload JPGs and/or PDFs to the form I have.

 

I believe I will need to allow 3 uploads once the whole form is done, but I'm trying to keep it small as I learn this.

 

Currently, the form saves the data to the database, and emails the results to a contact. This is fine - just what I need to do most of the time.

 

However, what I'm interesting in doing for this form is to allow the end user to upload/attached JPGs and/or PDFs and save then to the database (and I believe I will need to save the files in a folder on the server, I have one called "EmailedImages"),

and then email the results to the contact, including links that will allow the contact to click and download the attached JPGs and/or PDFs.

 

I haven't done this before, so can someone point me in the direction of how to do this, or should an example with the code I use:

<?php

$error = NULL;
$myDate = NULL;
$FullName = NULL;
$Email = NULL;

if(isset($_POST['submit'])) {

$myDate = $_POST['myDate'];
$FullName = $_POST['FullName'];
$Email = $_POST['Email'];


if(empty($FullName)) {
   $error .= '-- Enter your Full Name. <br />';
}

if(empty($Email)) {
   $error .= '-- Enter your Email. <br />';
}

if($error == NULL) {

$sql = sprintf("INSERT INTO myContactData(myDate,FullName,Email) VALUES ('%s','%s','%s')",

                        mysql_real_escape_string($myDate),
                        mysql_real_escape_string($FullName),
                        mysql_real_escape_string($Email);

                        
  if(mysql_query($sql)) {
  
    $error .= 'Thank you for contacting us.';
    
mail( "email@mywebsite.com", "Contact Request",

"Date Sent: $myDate\n Full Name: $FullName\n Email: $Email\n",
"From: $Email" );
  }
  else {
    $error .= 'There was an error in our Database, please Try again!';
  }
}
}
echo '<span class="textError">' . $error . '</span>';

?>



<form name="myform" action="" method="post">
<input type="hidden" name="myDate" size="45" maxlength="50" value="<?php echo date("F j, Y"); ?>" />


Full Name: <input type="text" name="FullName" size="45" maxlength="50" value="<?php echo $FullName; ?>" />
Email: <input type="text" name="Email" size="45" maxlength="50" value="<?php echo $Email; ?>" />


<input type="submit" name="submit" value="Submit" />

</form>

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

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.