Page 1 of 1
I have a problem with mail form it's .....
Posted: Wed Oct 29, 2003 3:44 am
by kujtim
this is an standard mail form
but if a would like to send a some thing else for example :first name: <input name="first" type="text" /><br />
what should i do please helpppp..
<html>
<body>
<form method="post" action="sendmail.php">
Email: <input name="email" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40">
</textarea><br />
<input type="submit" />
</form>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
mail( "
kujtim009@hotmail.com", "Feedback Form Results",
$message, "From: $email" );
header( "Location:
http://www.example.com/thankyou.html" );
?>
</body>
</html>
mail with attachments and everything
Posted: Wed Oct 29, 2003 5:07 am
by itsmani1
Code: Select all
<?php
// some local variables
$from_name = "Sender Name";
$from_email = "sender@server.ca";
$to_name = "Recipient Name";
$to_email = "recipient@server.ca";
$subject = "Fantastic Subject";
// headers need to be in the correct order...
$headers = "From: $from_name<$from_email>\n";
$headers .= "Reply-To: <$from_email>\n";
$headers .= "MIME-Version: 1.0\n";
// the following must be one line (post width too small)
$headers .= "Content-Type: multipart/related;
type="multipart/alternative"; boundary="----
=MIME_BOUNDRY_main_message"\n";
//
$headers .= "X-Sender: $from_name<$from_email>\n";
$headers .= "X-Mailer: PHP4\n"; //mailer
$headers .= "X-Priority: 3\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <$from_email>\n";
$headers .= "This is a multi-part message in MIME format.\n";
$headers .= "------=MIME_BOUNDRY_main_message \n";
$headers .= "Content-Type: multipart/alternative; boundary="----=MIME_BOUNDRY_message_parts"\n";
//plaintext section begins
$message = "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/plain; charset="iso-8859-1"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your text goes here
$message .= "blah blah -- plaintext version of the message\n";
$message .= "\n";
// html section begins
$message .= "------=MIME_BOUNDRY_message_parts\n";
$message .= "Content-Type: text/html;\n charset="iso-8859-1"\n";
$message .= "Content-Transfer-Encoding: quoted-printable\n";
$message .= "\n";
// your html goes here -- It didn't appear properly without
// the weird markup that outlook added after sending
$message .= "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\n";
$message .= "<HTML><BODY>\n";
$message .= "blah blah -- html version of the message\n";
// look ma, I'm referencing an img attachment (see below)
// watch out for weird markup!!!
$message .= "<IMG src=3D"cid:some_picture">\n";
$message .= "</BODY></HTML>\n";
$message .= "\n";
// this ends the message part
$message .= "------=MIME_BOUNDRY_message_parts--\n";
$message .= "\n";
// now we add attachments (images, etc)
$message .= "------=MIME_BOUNDRY_main_message\n";
$message .= "Content-Type: image/gif; \n name="some_picture.gif"\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-ID: <some_picture>\n";
$message .= "\n";
// (truncated for space)
$message .= "R0lGODlheAAZAKIHAMTExCQkJJOTk\n";
$message .= "eLo7wzDKSatVQ5R3u7dDUUjcZ34D\n";
$message .= "\n";
// etc...etc...etc...
//message ends
$message .= "------=MIME_BOUNDRY_main_message--\n";
// send the message
mail("$to_name<$to_email>", $subject, $message, $headers);
?>
Regardsssss
Posted: Wed Oct 29, 2003 5:37 am
by twigletmac
That's a lot of code
itsmani1 and pretty overcomplicated for what
kujtim is trying to do

.
kujtim -
Try this
Code: Select all
<html>
<head>
<title>Contact Form</title>
</head>
<body>
<form method="post" action="sendmail.php">
<p>
First Name: <input name="first" type="text" /><br />
Last Name: <input name="last" type="text" /><br />
Email: <input name="email" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40"></textarea><br />
<input type="hidden" name="action" value="post" />
<input type="submit" />
</p>
</form>
</body>
</html>
Now in sendmail.php
Code: Select all
<html>
<head>
<title>Contact form sent</title>
</head>
<body>
<?php
// first check if the form has been submitted
// we use $_POST because the values are coming via the POST method
if (isset($_POST['action']) && $_POST['action'] == 'post') {
$first_name = $_POST['first'];
$last_name = $_POST['last'];
$email = $_POST['email'];
$message = $_POST['message'];
$content =<<<END
A message has been received via the website:-
From: $first_name $last_name
Message:
$message
END;
$to_email = 'kujtim009@hotmail.com';
$subject = 'Feedback Form Results';
$headers = 'From: '.$email;
// we use @ to stop error messages showing to the user if the e-mail
// can't be sent because there's a problem on the server.
@mail($to_email, $subject, $content, $headers);
header('Location: thankyou.html');
}
?>
</body>
</html>
Mac
Posted: Wed Oct 29, 2003 5:40 am
by Nay
@itsmani1, that'll just confuse him. I've seen most of your posts, you might want to start advising people a little more rather than just post a plain code? He can go to EvilWalrus.com if he wanted a script.
@kujtim
Here's how you do it. Say you have a form:
Code: Select all
<form name="form" method="post" action="sendmail.php">
Name: <input type="text" name="sender_name" /><br />
From: <input type="text" name="email" /><br />
<textarea name="comment" rows="10" cols="50"></textarea><br />
<input type="submit" name="submit" value="Submit" />
</form>
That shouldn't be too hard for you. If your wondering the <br /> and <input />, these are XHTML syntax. You might want to start using XHTML since HTML is going to be extinct soon - well, not
so soon I guess. Anyhow, here's sendmail.php.
Code: Select all
<?php
// declare variables - makes life easier
$sender_name = $_POST['sender_name']; // use $_POST, since you know it's coming from a form with a POST method
$email = $_POST['email'];
$comment = $_POST['comment'];
$submit = $_POST['submit'];
// check if form is submitted
if(isSet($submit) && !empty($submit) {
// send mail
// declare variable "message" to send
$message = <<< MSG
Name: $sender_name\n
Message:\n
$comment
MSG;
// send mail
$send = mail("kujtim009@hotmail.com", "Feedback Form Results", $message, "From: $email");
// check if e-mail was sent
if(isSet($send)) {
header("Location: thankyou.html");
} else {
echo "Sorry, PHP could not send the e-mail";
}
} else {
echo "Error! Could not send mail!";
}
?>
Hope that helps!
-Nay
Posted: Wed Oct 29, 2003 5:41 am
by Nay
*snap*
Mac's always faster
............or I just type too slow
-Nay
Posted: Wed Oct 29, 2003 5:49 am
by twigletmac
mwha, ha, ha
Mac
Posted: Wed Oct 29, 2003 5:58 am
by Nay
Sing along in the PowerPuff Girls tune.
Huh
Jason, the most experianced useR.......
Wally, he's always flapping aRounD.........
MacKK, and the fastest typer........
PHPDN saves the day
fighting ASP
Trying to save the world
And then we're just in time
The PHPDN teammmmmmm
fighting M$
Trying to save the world
And then we're just in time
the PHPDN teammmmmmm
PHPDN!!!
Okay, I couldn't include all the dudes but yerr

. Oh sorry for getting off topic

but I just had to

.
-Nay
Posted: Wed Oct 29, 2003 1:44 pm
by m3rajk
Nay wrote:Sing along in the PowerPuff Girls tune.
Huh
Jason, the most experianced useR.......
Wally, he's always flapping aRounD.........
MacKK, and the fastest typer........
PHPDN saves the day
fighting ASP
Trying to save the world
And then we're just in time
The PHPDN teammmmmmm
fighting M$
Trying to save the world
And then we're just in time
the PHPDN teammmmmmm
PHPDN!!!
Okay, I couldn't include all the dudes but yerr

. Oh sorry for getting off topic

but I just had to

.
-Nay
still, i think that gets the most important ones.... jason, who i get the impression owns the site, and mac, who seems to spend every spare moment making sure this is an absolutely awesome place and extremely useful.
wally seems to help a lot, specially since we point those looking for scripts to his site.. hmm... maybe macgruff since he's rather good with giving a post that highlights the errors in constructive ways so that everyone learns from the mistake and knows how to fix it ... i mean instead of evil walrus since mcgruff seems to be here more....