# PHP Contact Form

**URL:** <https://forum.kirupa.com/t/php-contact-form/182738>\
**Category:** Uncategorized\
**Created:** [March 21, 2006, 3:38am UTC](https://forum.kirupa.com/t/php-contact-form/182738 "2006-03-21T03:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/itan/32/2274_2.png) [@itan](https://forum.kirupa.com/u/itan)\
**Post date:** [March 21, 2006, 3:38am UTC](https://forum.kirupa.com/t/php-contact-form/182738/1 "2006-03-21T03:38:16Z")

</div>

I try using this

[FONT=Courier New]\<form method="[COLOR=#0000ff] **POST** [/COLOR]" action="[COLOR=#0000ff] **mailer.php** [/COLOR]"\>  
\<input type=“text” name="[COLOR=#0000ff] **name** [/COLOR]" size=“19”\>\<br\>  
\<br\>  
\<input type=“text” name="[COLOR=#0000ff] **email** [/COLOR]" size=“19”\>\<br\>  
\<br\>  
\<textarea rows=“9” name="[COLOR=#0000ff] **message** [/COLOR]" cols=“30”\>\</textarea\>  
\<br\>  
\<br\>  
\<input type=“submit” value=“Submit” name="[COLOR=#0000ff] **submit** [/COLOR]"\>  
\</form\>[/FONT]

[FONT=Courier New]for my contact.htm[/FONT]  
[FONT=Courier New]and[/FONT]

[COLOR=#0000ff]\<?[/COLOR][COLOR=#000050]php[/COLOR] [COLOR=#006610]if[/COLOR]COLOR=#0000ff[/COLOR] [COLOR=#0000ff]{[/COLOR] [COLOR=#000050]$to[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#666666]“you@you.com”[/COLOR]; [COLOR=#000050]$subject[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#666666]“Form Tutorial”[/COLOR]; [COLOR=#000050]$name\_field[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#000050]$\_POST[/COLOR][COLOR=#0000ff][[/COLOR][COLOR=#666666]‘name’[/COLOR][COLOR=#0000ff]][/COLOR]; [COLOR=#000050]$email\_field[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#000050]$\_POST[/COLOR][COLOR=#0000ff][[/COLOR][COLOR=#666666]‘email’[/COLOR][COLOR=#0000ff]][/COLOR]; [COLOR=#000050]$message[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#000050]$\_POST[/COLOR][COLOR=#0000ff][[/COLOR][COLOR=#666666]‘message’[/COLOR][COLOR=#0000ff]][/COLOR]; [COLOR=#000050]$body[/COLOR] [COLOR=#0000ff]=[/COLOR] [COLOR=#666666]“From: $name\_field  
E-Mail: $email\_field  
Message:  
$message”[/COLOR]; [COLOR=#000050]echo[/COLOR] [COLOR=#666666]“Data has been submitted to $to!”[/COLOR]; [COLOR=#000050]mail[/COLOR][COLOR=#0000ff]([/COLOR][COLOR=#000050]$to[/COLOR], [COLOR=#000050]$subject[/COLOR], [COLOR=#000050]$body[/COLOR][COLOR=#0000ff])[/COLOR]; [COLOR=#0000ff]}[/COLOR] [COLOR=#006610]else[/COLOR] [COLOR=#0000ff]{[/COLOR] [COLOR=#000050]echo[/COLOR] [COLOR=#666666]“blarg!”[/COLOR]; [COLOR=#0000ff]}[/COLOR] [COLOR=#0000ff]?\>[/COLOR] [FONT=Courier New]for my mailer.php[/FONT]

[FONT=Courier New]It works, now the question is [COLOR=#000050]echo[/COLOR] [COLOR=#666666]“Data has been submitted to $to!”[/COLOR]; \<------ can i change it to my own .html page? or i mean redirect from other pages?[/FONT]

[FONT=Courier New]Thanks![/FONT]

---

<div class="post-metadata">

**Author:** ![melvijin](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@melvijin](https://forum.kirupa.com/u/melvijin)\
**Post date:** [March 21, 2006, 11:55am UTC](https://forum.kirupa.com/t/php-contact-form/182738/2 "2006-03-21T11:55:30Z")

</div>

mailer.php

```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
 E-Mail:$email_field

Message:
$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!!

---

<div class="post-metadata">

**Author:** ![itan](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/itan/32/2274_2.png) [@itan](https://forum.kirupa.com/u/itan)\
**Post date:** [March 21, 2006, 4:06pm UTC](https://forum.kirupa.com/t/php-contact-form/182738/3 "2006-03-21T16:06:49Z")

</div>

> [@melvijin](#):
>
> mailer.php
> 
> ```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
> E-Mail:$email_field
> 
> Message:
> $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](mailto: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

---

<div class="post-metadata">

**Author:** ![melvijin](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@melvijin](https://forum.kirupa.com/u/melvijin)\
**Post date:** [March 25, 2006, 1:50am UTC](https://forum.kirupa.com/t/php-contact-form/182738/4 "2006-03-25T01:50:45Z")

</div>

try to use javascript…

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

```

example…

```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
 E-Mail:$email_field

Message:
$message"; 
?>
<script language="javascript">
setTimeout(
"location.href='http://www.jassonthursday.com'", 
500);
</script>
<?
mail($to, $subject, $body); 
} else { 
echo "blarg!"; 
} 
?>

```

cheers!!!
