Jump to content

feedback form


Jaswinder

Recommended Posts

feed.php

<form action="feed1.php" method="post">
Name - <input type="text" name="name" /><br /><br />
Email - <input type="text" name="email" /><br /><br />
Subject - <input type="text" name="subject"/><br /><br />
message - <textarea rows="5" cols="10" name="message"></textarea><br /><br />
<input type="submit" value="Send mail" name="sub" />
</form>

 

 

feed1.php

 

<?php
extract($_POST);
$to="sehgal_jas@yahoo.com";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.="From:$name<$email>";
mail($to,$subject,$msg,$headers);
echo "Message sent successfully";
?>
 

error

 

"; mail($to,$subject,$msg,$headers); echo "Message sent successfully"; ?>

 

how to solve it??

 

Link to comment
Share on other sites

As long as PHP is installed, you're using the right file extension (typically .php, perhaps .php5), and you're using the long open tags (<?php) then the script should work. If it isn't working then probably one (or more) of those conditions aren't being met.

Link to comment
Share on other sites

so the code is correct........   may i try this code on another hosting??

 

No, it's not,

 

The proper format should be

From: user@domain.com will work// or quote a userNameFrom: "user" <user@domain.com>
Link to comment
Share on other sites

Take that and give us the result back if there is an error:

<?php

if (function_exists('mail')) {
    extract($_POST);
    $to = "sehgal_jas@yahoo.com";
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers.= <<<EOD
From: "$name" <$email>
EOD;
} else {
    echo 'mail() has been disabled'; exit;
}
// send message
if (mail($to, $subject, $message, $headers)) {
    echo "mail send ... OK";
} else {
    echo "mail send ... ERROR!";
}

Make sure that the "$subject" and the "$message" variables are defined!

Link to comment
Share on other sites

He-he, that's life php coding :)

 

So, try that:

<?php

if (function_exists('mail')) {
    extract($_POST);
    $to = "sehgal_jas@yahoo.com";
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers.= <<<EOD
From: "$name" <$email>
EOD;

// send message
    if (mail($to, $subject, $message, $headers)) {
        echo "mail send ... OK";
    } else {
        echo "mail send ... ERROR!";
    }
} else {
    echo 'mail() has been disabled';
    exit;
}

Make sure all variables are defined in proper way.

Link to comment
Share on other sites

its not showing that also... so i just changed the host.. its working great know and i got the email.. :)

 

about <<<EOD (heredoc)

what exactly it do... i search the web ,  not get clear much,,,i think it is used to write multiple lines with single(') and double quotes(") ?? is it

 

and also about this line

 

From: "$name" <$email>

Link to comment
Share on other sites

A here document is a special-purpose code block and allows me easily to quoting/escaping the strings effectively.

About < (<) and > (>), there are html character entities, so to display for instance a less than sign we must write: < or <

But...when you try to send emails you can use both of them, I think.  

For example:

From: "$name" <$email>

Link to comment
Share on other sites

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.