I tried to add file sending option in my contact form, but unsuccessfully.
http://www.balti.ee/proov/index.php?page=Kontakt
Can anyone teach me how to do it?
It would really help me alot.
Thanks.
How to add file sending option to contact form ?
Re: How to add file sending option to contact form ?
You have to add parameter 'enctype' to Your formIndrek wrote:I tried to add file sending option in my contact form, but unsuccessfully.
http://www.balti.ee/proov/index.php?page=Kontakt
Can anyone teach me how to do it?
It would really help me alot.
Thanks.
and then You have to use super-global variable $_FILES - take a look here:
http://php.net/manual/en/reserved.varia ... bles.files
Re: I tried
OK, here is what You want (I hope so):Indrek wrote:I tried to do this, but it is still not working.
Maby i did something wrong?
- You have to create user defined plugin
- name it
Code: Select all
contactform
Code: Select all
if (isset($_POST['ok_contactform'])) {
global $gCms;
echo '<div>';
echo 'Your Name:' . $_POST['name'] . '<br>';
echo 'Your Email:' . $_POST['email'] . '<br>';
echo 'Subject:' . $_POST['subject'] . '<br>';
echo 'Message:' . $_POST['message'] . '<br>';
if (($_FILES['file']['error']) > 0 ){
echo '<strong>And where is file?</strong>';
}
else {
$try = 0;
$dest_filename = '_contactform_' . $_FILES['file']['name'];
$dest_file = $gCms->config['uploads_path'] . '/' . $dest_filename;
while (file_exists($dest_file)) {
$dest_filename = $try . '_contactform_' . $_FILES['file']['name'];
$dest_file = $gCms->config["uploads_path"] . '/' . $dest_filename;
$try++;
}
$_FILES['file']['name'] = $dest_filename;
if ( ! move_uploaded_file( $_FILES['file']['tmp_name'], $dest_file)) {
echo '<strong>Error during copy file.</strong>';
}
else {
echo 'Saada Fail:' . $_FILES['file']['name'];
}
}
echo '</div>';
}
else {
echo '<div>';
echo '<form enctype="multipart/form-data" action="" method="post" name="contactForm" style="font-weight: bold;">';
echo '<input type="hidden" name="MAX_FILE_SIZE" value="100000">';
echo 'Your Name:';
echo '<input type="text" name="name" value="" size="50" style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;">';
echo 'Your Email Address:';
echo '<input type="text" name="email" value="" size="50" style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;">';
echo 'Subject:';
echo '<input type="text" name="subject" value="" size="50" style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;">';
echo 'Saada Fail:';
echo '<input type="file" name="file" value="" size="50" style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;">';
echo 'Message:';
echo '<TEXTAREA NAME="message" COLS="40" ROWS="10" style="width: 350px; border: solid 1px black; display: block; margin-bottom: 7px;"></textarea>';
echo '<input type="submit" name="ok_contactform" value="Submit">';
echo '<input type="reset" value="Clear">';
echo '</form>';
echo '</div>';
}
Code: Select all
{contactform}
File uloaded by this plugin (smaller than 100kB) will be in Your uploads directory. If no, write back.
contact form
I used your code and it did work.
But, is it possible to send the file and text entered in fields to my email address from contact form.
I would like to make something like is in this page:
http://www.terraver.ee/index.php?page=32
Could you help?
It would mean a world to me.
Thanks.
But, is it possible to send the file and text entered in fields to my email address from contact form.
I would like to make something like is in this page:
http://www.terraver.ee/index.php?page=32
Could you help?
It would mean a world to me.
Thanks.
Re: contact form
If You want to send plain text data by e-mail, just use simple PHP function 'mail()' - see http://www.php.net/manual/en/function.mail.php . But if You want to send any attachment with e-mail message, it is not so easy - best way is to do this with some existed php class, like this one:Indrek wrote: But, is it possible to send the file and text entered in fields to my email address from contact form.
http://www.phpclasses.org/browse/package/1077.html
By the way, in case You have to include and use any class (defined in external file), module will be better then plugin.
I am sorry, You have to study a little bit, but don't worry - recommended class is very simple and quite well documented (example is also included).
Re: contact form
For saving Your life seeIndrek wrote:It would mean a world to me.
http://forum.cmsmadesimple.org/viewtopi ... ight=#2483