Avatar of jonathanduane2010
jonathanduane2010 asked on

php and sending me a mail from my webpage

Hi,

i have an uploadfiles.php on my website http://zyder.actionit.ie and i want when siomeone submits a file to send me a mail to info@domainname.com so far i have

<?php

$ path = "files/";

$path = $path . basename( $_FILES['userfile']['name']);



if(move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) {

echo "Successful upload of ". basename($_FILES['photofile']['name']);

<input type="submit" value="Submit CV" /mail('info@domainname.com', 'UPLOAD COMPLETE',

} else{

what else do you i need to get to send me an email with the attachment?? i have tried

<input type="submit" value="Submit CV" /mail('info@domainname.com', 'UPLOAD COMPLETE', NULL);>
PHPHTMLWeb Development

Avatar of undefined
Last Comment
Marco Gasi

8/22/2022 - Mon
Marco Gasi

Perhaps I'm missing something, but why use <input> tag?

This should work:

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) {
  echo "Successful upload of ". basename($_FILES['photofile']['name']);
  mail('info@domainname.com', 'UPLOAD COMPLETE');
} else{
  mail('info@domainname.com', 'UPLOAD FAILED');
}

Or I'm wrong?
ASKER
jonathanduane2010

ok i have tried that on this page http://zyder.actionit.ie/index-2.html and it didnt send anything?

Sorry i am completely new to php

(also how do i get to bring it back to the page i was just on) instead of having just a blank page?
Marco Gasi

Can you post complete code you are using, please? Without that I can't help you anymore...
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER
jonathanduane2010

html code first and uploadfiles.php second

thank you
<h2>Register Today</h2>
                                                                        <h4>Submit your details below and register with us today</h4>
                                                                        <img alt="" src="images/4page_img5.jpg" class="img-indent" /><br>
                                                                        <h4>&nbsp;</h4><form enctype="multipart/form-data" action="upload_files.php" method="POST">
                                <p>
                                  <input name="userfile" type="file" class="rowElem" />
                                  <br />
                                <input type="submit" value="Submit CV" />
                                </p>
</form>

Open in new window

<?php

$ path = "files/";

$path = $path . basename( $_FILES['userfile']['name']); 



if(move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) {
  echo "Successful upload of ". basename($_FILES['photofile']['name']);
  mail('jonathan@actionit.ie', 'UPLOAD COMPLETE');
} else{
  mail('info@domainname.com', 'UPLOAD FAILED');
}

Open in new window

Marco Gasi

At the first look, I see you have an erroneous space: you have $ path instead to $path and this breaks your script. Try to fix it.
ASKER
jonathanduane2010

ok i have done that and have uploaded it to my hosting server but i might have to get them to enable php before i can properly test it, is that correct?

Thanks for your help
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Marco Gasi

I don't know your provider's politics, but yes, php must be enabled. Most providers has php enabled by default. To check if your provider has php installed, create a simple file named phpinfo.php. In this file write these lines

<?php
phpinfo();
?>

Then upload fle to your web server and load it into your browser: you should see a page with all php environment informations.

Let me know if you encounter any problems.

Cheers
ASKER
jonathanduane2010

ok i have tried that and the php info comes up http://zyder.actionit.ie/info.php

but the mail doesnt come throught when i hit "submit cv" ?
Marco Gasi

I'm stupid!!! mail function requires four parameters:

<?php

$path = "files/";

$path = $path . basename( $_FILES['userfile']['name']);

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) {
  echo "Successful upload of ". basename($_FILES['photofile']['name']);
  mail('jonathan@actionit.ie', 'UPLOAD COMPLETE', '', 'From: valid@email.com');
} else{
  mail('info@domainname.com', 'UPLOAD FAILED' '', 'From: valid@email.com');
}

I'm sorry

Cheers
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
jonathanduane2010

thanks marqus

i tried this in dreamweaver and got the following message, should i be worried??
ASKER CERTIFIED SOLUTION
Marco Gasi

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question