Jump to content

Archived

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

timgetback

Ok simple question looking for simple answer.....

Recommended Posts

I want to send html variables that are using the post method via php mail to an account........
here is my mail.php file:

<?
$to = "mail@mailer.com";
$subject = "Email Info";
$info1 = $_POST['name']
$info2 = $_POST['age']
$body = "$info1 , $info2";
if (mail($to, $subject, $body)) {
  echo("<p>message successfully sent!</p>");
} else {
  echo("<p>Error Try again...</p>");
}
?>



Ok... i used action= mail.php however it doesnt show whether or not the message was sent or not... allso the account is not recieving the message if anyone can deliever a straight forward answer it would be great.

Share this post


Link to post
Share on other sites
If you're not seeing anything, my first suggestion would be to change <? to <?php
The former is not supported by all installations (or servers) with php. I've seen people on these forums before with this problem.

also, with your form, you are doing method="post" and not method="get" right?

Share this post


Link to post
Share on other sites
[quote author=timgetback link=topic=102757.msg408306#msg408306 date=1154544225]
Ok... i used action= mail.php [/quote]

action = mail.php or action="mail.php"?

Share this post


Link to post
Share on other sites
Well it doesn't sound like the script is being run for some reason, or at least it's not getting to the IF statement. Try putting an echo in on its own somewhere just to make sure.

Share this post


Link to post
Share on other sites
you're missing a ; after $_POST['name'], and after $_POST['age'].

the reason you didn't see anything is probably that you have display error off.

Share this post


Link to post
Share on other sites
how do you turn that on??? im really new to this stuff. thanks it tells me that the message was succesfull but when i check my email theres nothing there.

Share this post


Link to post
Share on other sites
Ok i got another problem.... when i send my mailto.php file with the following code:

[code]<?php
$to = "email@domain.com";
$subject = "Email Info";
$info1 = $_POST['info1'];
$info2 = $_POST['info2'];
$body = "info1: $info1 ,info2: $info2";
if (mail($to, $subject, $body)) {
  echo("<p>message successfully sent!</p>");
} else {
  echo("<p>Error Try again...</p>");
}

?>

[/code]

It changes the mail function to an array function so it ends up like this when i load it:

[code]<?php
$to = "email@domain.com";
$subject = "Email Info";
$info1 = $_POST['info1'];
$info2 = $_POST['info2'];
$body = "info1: $info1 ,info2: $info2";
if (array($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Error Try again...</p>");
}

?>

[/code]

What should i do? cause when i leave the array function in, and add the mail function it also changes
Before:
[code]if (array($to, $subject, $body)) {
  echo("<p>Login successfully sent!</p>")
  mail($to, $subject, $body);
} else {
  echo("<p>Error Try again...</p>");
}

?> [/code]
After:
[code]if (array($to, $subject, $body)) {
  echo("<p>Login successfully sent!</p>")
  array($to, $subject, $body);
} else {
  echo("<p>Error Try again...</p>");
}

?> [/code]

Share this post


Link to post
Share on other sites

×

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.