Jump to content

Webform don't send data to email


hassan1214

Recommended Posts

Hello,

 

I need help on webfrom code . As I have mentioned email address into action= filed but not getting any email data on the prescribed email address. www.icampk.com please check contact page for ref.

<h3 class="p2">Contact Form</h3>
            <form id="contact-form" action="action="/Default.aspx?A=Form&[email protected]&Subject=This+is+email+subject&[email protected]&PageID=/index.html"" method="post" enctype="multipart/form-data">
              <fieldset>
                <label><span class="text-form">Your Name:</span>
                  <input name="p1" type="text">
                </label>
                <label><span class="text-form">Your Email:</span>
                  <input name="p2" type="text">
                </label>
                <label><span class="text-form">Subject:</span>
                  <input name="p3" type="text">
                </label>
                <div class="wrapper">
                  <div class="text-form">Your Message:</div>
                  <div class="extra-wrap">
                    <textarea></textarea>
                    <div class="clear"></div>
                    <div class="buttons"> <a class="button" href="#">Clear form</a> <a class="button" href="#">Send message</a> </div>
Link to comment
https://forums.phpfreaks.com/topic/284695-webform-dont-send-data-to-email/
Share on other sites

Can you share with us the PHP code? THe code that you use to send the e-mail

 

I'm looking you html and:

"<textarea></textarea>" here you write your mensaje, but, you have not set a "name".

 

You should write:

<textarea name="message"></textarea>

 

And then, in PHP code, use $_POST['"message"]

Wait wait wait wait...

First, you ahve very mucho problems.

 

Look... I'm in your site, and I go to the file when you process your e-mail (http://www.icampk.com/contact-form-handler.php) and I'm seen that:

You have not support to PHP in your server... else, we should not see the PHP code.

 

That is your PHP code:

$errors = '';
$myemail = '[email protected]';
if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['subject']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}
$name = $_POST['p1'];
$email_address = $_POST['p2'];
$email_address = $_POST['p3'];
$message = $_POST['message'];
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i",
$email_address))
{
$errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
$to = $myemail;
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n Name: $name \n ".
"Email: $email_address\n Message \n $message";
$headers = "From: $myemail\n";
$headers .= "Reply-To: $email_address";
mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
}

And, look the first lines...

if(empty($_POST['name']) ||

and bla bla bla...

 

Is obviolsy that... $_POST['name'] is EVERYTIME empty, because $_POST['name'] not exist... only exist $_POST['p1']

 

All that is is empty:

if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['subject']) ||
empty($_POST['message']))

 

You should modify that... replace "name" for "p1", and "email" for "p2" and bla bla bla.

 

Then i see:

$message = $_POST['message'];

But, $_POST['message'] is not existing! remember add "name=message" at your <textarea>

 

And then, you use: mail($to,$email_subject,$email_body,$headers); but, $email_body is a string defined for your... You should use "$message"...

 

Please, dont copy and past code for others site... is better learn about PHP, read about PHP, read examples, but NEVER COPY AND PAST... I have very much experience with PHP and when I copy and past, EVERYTIME have problems.

 

If you continue having problems, report us here.

Remember:

if( empty($errors))

is FASLE becasuse that is TRUE:

if(empty($_POST['name']) ||
empty($_POST['email']) ||
empty($_POST['subject']) ||
empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}

 

and then, your code not send the e-mail.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.