PDA

View Full Version : PHP Contact Form



itan
March 20th, 2006, 10:38 PM
I try using this

<form method="POST" action="mailer.php">
<input type="text" name="name" size="19"><br>
<br>
<input type="text" name="email" size="19"><br>
<br>
<textarea rows="9" name="message" cols="30"></textarea>
<br>
<br>
<input type="submit" value="Submit" name="submit">
</form>

for my contact.htm
and

<?php if(isset($_POST['submit'])) { $to = "you@you.com"; $subject = "Form Tutorial"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?> for my mailer.php

It works, now the question is echo "Data has been submitted to $to!"; <------ can i change it to my own .html page? or i mean redirect from other pages?

Thanks!

melvijin
March 21st, 2006, 06:55 AM
mailer.php



<?php
if(isset($_POST['submit'])) {
$to = you@you.com;
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail:$email_field\n
Message:\n$message";
?>
Data has been submitted to <a href="<?=$to;?>"><?=$to;?></a>
<?
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>



try that man, i'm sure it will work... cheers!!

itan
March 21st, 2006, 11:06 AM
mailer.php



<?php
if(isset($_POST['submit'])) {
$to = you@you.com;
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail:$email_field\n
Message:\n$message";
?>
Data has been submitted to <a href="<?=$to;?>"><?=$to;?></a>
<?
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>



try that man, i'm sure it will work... cheers!!


----------------------------------------------------------

yes bro this is same ad mine. well i need to rederect this part
Data has been submitted to <a href="<?=$to;?>"><?=$to;?></a>
<? i dont want afer sending the form it will say Data has been submitted to you@you.com all i need is when i send the form it will go to another html or php. or some kind like this www.jassonthursday.com (http://www.jassonthursday.com)

thanks bro! God bless

melvijin
March 24th, 2006, 08:50 PM
try to use javascript..





<script language="javascript">
setTimeout("location.href='yourlink'", delay);
</script>



example...




<?php
if(isset($_POST['submit'])) {
$to = you@you.com;
$subject = "Form Tutorial";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$body = "From: $name_field\n E-Mail:$email_field\n
Message:\n$message";
?>
<script language="javascript">
setTimeout(
"location.href='http://www.jassonthursday.com'",
500);
</script>
<?
mail($to, $subject, $body);
} else {
echo "blarg!";
}
?>



cheers!!!