April 20, 200917 yr Hey all well the forum idea is put on hold since me and my friend want to make a webform inquiry for classifeds <title>Thanks for registering</title><?php /* Subject and Email variables */ $emailSubject = '1st weekly Competition Central Contest Entry'; $webMaster = 'registration@invercargillcentral.co.nz'; /* Gathering Data Variables */ $email = $_POST['email']; $name = $_POST['name']; $gender = $_POST['gender']; $address = $_POST['address']; $phone = $_POST['phone']; $Day = $_POST['Day']; $Month = $_POST['Month']; $Year = $_POST['Year']; $filename=$_FILES["Upload"]["name"]; $filetype=$_FILES["Upload"]["type"]; $filesize=$_FILES["Upload"]["size"]; $filetemp=$_FILES["Upload"]["tmp_name"]; if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword") { $body = <<<EOD <br><hr><br> Email: $email <br> Name: $name <br> Gender: $gender <br> Address: $address <br> Phone: $phone <br> DOB: $Day $Month $Year <br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $fp = fopen($strresume, "rb"); $file = fread($fp, $strresume_size); $file = chunk_split(base64_encode($file)); $num = md5(time()); $headers .= "Content-Type:".$strresume_type." "; $headers .= "name=\"".$strresume_name."\"r\n"; $headers .= "Content-Transfer-Encoding: base64\r\n"; $headers .= "Content-Disposition: attachment; "; $headers .= "filename=\"".$strresume_name."\"\r\n\n"; $headers .= "".$file."\r\n"; $headers .= "--".$num."--"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results Rendered as HTML*/ $theResults = <<<EOD EOD; echo "$theResults"; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { background-image: url(file:///D|/Invercargill%20Central%20final/images/background.jpg); background-repeat: repeat; } .completed_registration { position: absolute; left: 13px; top: 13px; width: 937px; height: 1515px; background-color: #E9ECDF; } --> </style> <link href="../css/style.css" rel="stylesheet" type="text/css"> </head> <body> <div class="layout"> <div class="completed_registration">Thank you for registering with invercargillcentral.co.nz. You are now in the draw for our monthly major prize. Good Luck! </div> </div> </body> </html> ///--------- 103 line is here I get a error at 103 but I dunno why since its at the end of the line any help with this would be aprecated
April 20, 200917 yr If an error is thrown right at the end of the file, my own experience is that it's always caused by failing to close all open curly brackets. I think you've failed to close the one that opens with the IF statement - sorry if I've read that wrong. You may find tools like Eclipse, Notepad++ or Textwrangler useful in these situations as they all allow you to match opening and closing brackets which can make these errors obvious. Eclipse with a PHP plugin will also highlight such errors.
April 20, 200917 yr if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword") { Looks like you haven't closed the if statement?
April 21, 200917 yr Author ok fixed the white error message but get on line 47 this message as it sends the mail Warning: fread(): supplied argument is not a valid stream resource in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/PHP/Week1competition.php on line 47
April 21, 200917 yr I didn't pay any attention to your code yesterday, just scanned the brackets. This error is because the file $strresume doesn't exist. Try using fopen on $filetemp and changing all variable references that start $strresume - the ones to change to should be self-explanatory. I think the way you construct the email may throw more errors once you get beyond this - I think the headers look incomplete for a multipart/mixed email. If you try Googling 'php mail attachment' you'll find a few pages offering complete scripts, but I'd recommend you take a look at Swiftmailer. The great advantage is that it allows the sending of email via SMTP which seems to help avoid some intermittent problems with emails appearing corrupt in some clients. One last thought - if you're new to PHP and using snippets of code from various sources to put scripts together, you may find it easier to integrate code from different places if you use single and double quotes around strings, rather heredoc quoting. That is, however, a personal taste and if you find heredoc or newdoc quoting works for you, there's no need to change.
April 22, 200917 yr Author I've gone and replaced the php wit something that works now just I want to change the format to image types when it attaches to the email if($filetype=="application/octet-stream" or $filetype=="text/plain" or $filetype=="application/msword") I think I got the right code for it ("image/gif")
April 29, 200917 yr Author Ok I got something working though I got this error message on line 4 Warning: copy(home/www/httpdocs/uploadsQuagmire.gif) [function.copy]: failed to open stream: No such file or directory in /var/www/vhosts/invercargillcentral.co.nz/httpdocs/pages/Competitions/uploadmanager.php on line 4 I think i've got the wrong path or something I use filezilla to upload to the server here is the code <?phpif (is_uploaded_file($_FILES['Images']['tmp_name'])) { copy($_FILES['Images']['tmp_name'], "home/www/httpdocs/uploads".$_FILES['Images']['name']); } else { echo "<p>Potential script abuse attempt detected.</p>"; } ?> anyone could inform me of what the error means and what where I could start looking for this directory I think its looking for would be a great help
Create an account or sign in to comment