danielwilliamsongle Posted June 3, 2013 Share Posted June 3, 2013 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: <?phpsession_start ();//check if its not logged or its admin redirect to login pageinclude ("scheck.php");//Connect to dbinclude ("conn.php");//Select dbinclude ("select.php");//header codesinclude ("headercodes.php");//PAGE DISPLAY//******************* PAGE CODES HEREforeach ($_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 HEREinclude ("footercodes.php");}?> Your help is greatly appreciated Regards Daniel Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/ Share on other sites More sharing options...
davidannis Posted June 3, 2013 Share Posted June 3, 2013 Use the php mail function. http://php.net/manual/en/function.mail.php If you have trouble post again and we'll help. Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1433857 Share on other sites More sharing options...
cpd Posted June 3, 2013 Share Posted June 3, 2013 Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1433882 Share on other sites More sharing options...
danielwilliamsongle Posted June 7, 2013 Author Share Posted June 7, 2013 Thanks for the info, so the code I have is: <?php// The message$message = "Product uploaded";// Sendmail('admin@me.co.uk', 'Product uploaded My Subject', $message);?> Where you i place this in my code? I have tried a couple of places and I am getting an error. Thanks again for the help Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434750 Share on other sites More sharing options...
dalecosp Posted June 7, 2013 Share Posted June 7, 2013 I have tried a couple of places and I am getting an error. It would really help anyone who seriously wants to help if you would post the code as it exists right now, and the exact error message... Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434751 Share on other sites More sharing options...
danielwilliamsongle Posted June 7, 2013 Author Share Posted June 7, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434753 Share on other sites More sharing options...
davidannis Posted June 8, 2013 Share Posted June 8, 2013 Did you include the line <?php You shouldn't. You're already in php. Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434789 Share on other sites More sharing options...
cpd Posted June 8, 2013 Share Posted June 8, 2013 (edited) Edited June 8, 2013 by cpd Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434809 Share on other sites More sharing options...
danielwilliamsongle Posted June 8, 2013 Author Share Posted June 8, 2013 Ok, where should I place this code in the full page of code? This is the exact code I presume I should input: // The message$message = "Product uploaded";// Sendmail('admin@me.co.uk', 'Product uploaded My Subject', $message); Can you let me know? Thanks for your help Regards Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434900 Share on other sites More sharing options...
Solution davidannis Posted June 9, 2013 Solution Share Posted June 9, 2013 (edited) 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 June 9, 2013 by davidannis Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1434987 Share on other sites More sharing options...
danielwilliamsongle Posted June 9, 2013 Author Share Posted June 9, 2013 Thanks all for your help - it now works Quote Link to comment https://forums.phpfreaks.com/topic/278726-email-upload-confirmation-code-help/#findComment-1435034 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.