For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > September 2005 > Mail-form php









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Mail-form php
Yvonne

2005-09-14, 6:57 pm

Hi everyone!

I have a problem with php. I guess I am tired because I sure this is
simple, but I just can't make a simple mailscript work. I have to pages.
One htm and one php. Here's the code:

contact.html
<html>
<head>
<title>Kontakt</title>
<link rel="stylesheet" href="../css/style.css">

</head>
<body>
<h1>Kontakt</h1>
<h2>Kontakt</h2>
<form method="post" action="send.php">
Namn:<br><input name="name" type="text" size="30"><br><br>
Email:<br><input name="email" type="text" size="30"><br><br>
Ärende:<br><input name="subject" type="text" size="30"><br><br>
Meddelande:<br><textarea name="msg" cols="25"
rows="6"></textarea><br><br>
<input type="reset" value="Reset"> <input type="submit"
value="Send">
</form>
</body>
</html>

send.php
<html>
<head>
<title>Kontakta oss</title>
<link rel="stylesheet" href="../css/style.css">

</head>
<body>

<?php
$to = "clownen2005@telia.com"; //
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];
$sub = "form to mail";
$messub = "Subject: ".$subject."\n";
$mesmsg .= "Message: ".$msg."\n";
$mesname .= "Name: ".$name."\n";
$mesemail .= "Email: ".$email."\n";
if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
echo " <h3>Du måste fylla i alla fält.</h3>";
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
$email)) {
print " <h3>Din email är felaktig.</h3>";
} else {
mail('$to', $sub, $messub, $mesmsg, $mesname, $mesemail);
print " <h3><center>Tack ".$name." för att du kontaktar
oss.</center></h3>";
}
?>
</body>
</html>

Can anyone tell me what I am doing wrong?

Thanks
Yvonne
Stefan Rybacki

2005-09-14, 6:57 pm

Yvonne wrote:
> Hi everyone!
>
> I have a problem with php. I guess I am tired because I sure this is
> simple, but I just can't make a simple mailscript work. I have to pages.
> One htm and one php. Here's the code:
>
> contact.html
> <html>
> <head>
> <title>Kontakt</title>
> <link rel="stylesheet" href="../css/style.css">
>
> </head>
> <body>
> <h1>Kontakt</h1>
> <h2>Kontakt</h2>
> <form method="post" action="send.php">
> Namn:<br><input name="name" type="text" size="30"><br><br>
> Email:<br><input name="email" type="text" size="30"><br><br>
> Ärende:<br><input name="subject" type="text" size="30"><br><br>
> Meddelande:<br><textarea name="msg" cols="25"
> rows="6"></textarea><br><br>
> <input type="reset" value="Reset"> <input type="submit"
> value="Send">
> </form>
> </body>
> </html>
>
> send.php
> <html>
> <head>
> <title>Kontakta oss</title>
> <link rel="stylesheet" href="../css/style.css">
>
> </head>
> <body>
>
> <?php
> $to = "clownen2005@telia.com"; //
> $name = $_POST['name'];
> $email = $_POST['email'];
> $subject = $_POST['subject'];
> $msg = $_POST['msg'];
> $sub = "form to mail";
> $messub = "Subject: ".$subject."\n";
> $mesmsg .= "Message: ".$msg."\n";
> $mesname .= "Name: ".$name."\n";
> $mesemail .= "Email: ".$email."\n";
> if(empty($name) || empty($email) || empty($subject) || empty($msg)) {
> echo " <h3>Du måste fylla i alla fält.</h3>";
> }
> elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$",
> $email)) {
> print " <h3>Din email är felaktig.</h3>";
> } else {
> mail('$to', $sub, $messub, $mesmsg, $mesname, $mesemail);


remove the 's ^

> print " <h3><center>Tack ".$name." för att du kontaktar
> oss.</center></h3>;
> }
> ?>
> </body>
> </html>
>
> Can anyone tell me what I am doing wrong?
>
> Thanks
> Yvonne

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com