Welcome to Creative Nation!

Welcome to Creative Nation, . Feel free to browse our forums and help yourself to all our free tutorials, images, and recources!

Download

To download this script go back to article »

Member Login

Lost your password?

Not a member yet? Sign Up!

[PHP] Contact form guide
  • [PHP] Contact form guide Announ10
  • [PHP] Contact form guide Tutori10
  • [PHP] Contact form guide Profil10
  • [PHP] Contact form guide New_pr10
  • [PHP] Contact form guide Back_t10


The next generation of web design.


You are not connected. Please login or register

[PHP] Contact form guide

3 posters

Go down  Message [Page 1 of 1]

1[PHP] Contact form guide Empty [PHP] Contact form guide 8/24/2011, 1:43 pm

Daniel

Daniel


Hello and welcome to my first tutorial on creative nation,
Here is how to make a basic php contact form with Name, E-Mail address and Content fields.

Step 1 : Add this to your html page
Code:
<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>

The code you see above shows the display elements.

Step 2: Create a php file called "mailer.php" please ensure that it is in the same directory as your html page.

Step 3 : The php file should contain

Code:

<?php
if(isset($_POST['submit'])) {
$to = "you@you.com";
$subject = "Contact Form Response";
$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 "Something Went wrong, please try again!";
}
?>


But where it says you@you.com change it to your email address.

There you have it, your own php contact form Smile
I will do a line by line breakdown and guide with pictures soon.

2[PHP] Contact form guide Empty Re: [PHP] Contact form guide 8/24/2011, 2:45 pm

virtuosity

virtuosity

Thank you very much. I will try this ASAP. Going to get my domain name sometime this week!

3[PHP] Contact form guide Empty Re: [PHP] Contact form guide 8/25/2011, 7:48 am

Daniel

Daniel


@virtuosity

Glad it has helped

~Dan

4[PHP] Contact form guide Empty Re: [PHP] Contact form guide 8/25/2011, 1:49 pm

virtuosity

virtuosity

So I tried to do this to an index page on my PC and it didn't work. Why?

5[PHP] Contact form guide Empty Re: [PHP] Contact form guide 8/26/2011, 11:08 am

Saxaca

Saxaca


You'll need to have PHP installed...

6[PHP] Contact form guide Empty Re: [PHP] Contact form guide 8/26/2011, 2:50 pm

virtuosity

virtuosity

Hmm guess I won't be able to do this since I have no idea how to do that.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

.

Free forum | ©phpBB | Free forum support | Report an abuse | Forumotion.com.