Jump to content

Email upload confirmation code help


Go to solution Solved by davidannis,

Recommended Posts

Hi all,

 

I have a website in which users can upload listings for me to then confirm via the CMS. At present I have it set that admin approval is requested so that there is no spam. What I would like to do is have it that when somebody uploads an item that I recieve an email so that I know to go into the CMS to confirm it.

 

I´m just not sure how!!!! Can anyone help me with this?

 

The page code is as follows:

 

<?php
session_start ();

//check if its not logged or its admin redirect to login page
include ("scheck.php");


//Connect to db
include ("conn.php");

//Select db
include ("select.php");

//header codes
include ("headercodes.php");

//PAGE DISPLAY
//******************* PAGE CODES HERE


foreach ($_POST as $field => $value) {

if (!$value){
$err .="<center><br><font color=#f69900><b>$field</b></font> is required<br>";
}
}
if ($err){
echo $err;
echo"<br><br><a href='javascript:history.go(-1)'>Back</a>";
include ("footercodes.php");
exit;
}

else {


//$file = trim(addslashes($_POST['file']));
//$manufacturer = trim(addslashes($_POST['manufacturer']));
//$listingdate = trim(addslashes($_POST['listingdate']));
//$views = trim(addslashes($_POST['views']));


//check if user create new name for group or use current names.
//if ($_POST[imggroup]=="Create New Category")
//{
//$imggroup=$_POST[newproduct];
//}
//else
//{
//$imggroup=$_POST[imggroup];
//}
    

    
$listingdate= date('j F Y');
$views=0;
$username=$_SESSION ["valid_user"];
$confirm=0;
    
    
//file upload
    if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000000))
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
    }
  else
    {
 
   

    if (file_exists("uploads/products/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists change your file name. ";
      }
    else
      {
       $random_digit=rand(0000,9999);
      $_FILES["file"]["name"]=$random_digit.$_FILES["file"]["name"];
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "uploads/products/" . $_FILES["file"]["name"]);
      echo "<center><br><b>Thank You!</b>";
      $file=$_FILES["file"]["name"];
      
      //Create columns and records in database with file

    $sql="INSERT INTO `products` (`category`,`county`,`name`,`condition`,`partno`,`price`,`file`,`manufacturer`,`listingdate`,`views`,`username`,`confirm`,`description`)
    VALUES
    ('$_POST[category]','$_POST[county]','$_POST[name]','$_POST[condition]','$_POST[partno]','$_POST[price]','$file','$_POST[manufacturer]','$listingdate','$views','$username','$confirm','$_POST[description]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "<br>Your product has been uploaded successfully , as soon as admin confirm it , it will be listed</center><br/>";
    }
  }
  }

  else {
 
  echo "You did not specify any image to upload or your image is not acceptable (Acceptable types : .JPG and .GIF) <br> Please make sure your image name does not have space or special characters";
  }
//******************* PAGE CODES ENDS HERE
include ("footercodes.php");

}
?>

 

 

Your help is greatly appreciated

Regards

 

Daniel

Link to comment
Share on other sites

Hi

 

I placed the mail code under the follwoing line:

if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "<br>Your product has been uploaded successfully , as soon as admin confirms it , it will be listed</center><br/>";

 

And the error I get is:

 

Parse error: syntax error, unexpected '<' in /home/danielwi/public_html/uploadproduct.php on line 100

 

I´m sure it´s just a case of the mail code being in the wron place but I´m not sure where to place it

 

Thanks

Link to comment
Share on other sites

  • Solution

the place you put it in post 6 seems seems fine to me.

 

Also, when you post code please use the code tags (the "<>" symbol in the editor). It will make your code easier to read.

Edited by davidannis
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.