Jump to content

template contact form help


nzGoner

Recommended Posts

i bought this template and going well, but i am stuck with the contact page, i want the user to be able to fill the contact form and send it to my mailbox.. yes i have tried it myself and also build my own contact.php . But the template coding is a bit confusing for me

 

i need some help please  :'(

 <div id="content">		
        <div class="bg-cont png">
            <div class="indent-main">
                <div class="container">
                    <div class="col-1">
                        <div class="box">
                             <form action="" id="form2">
                            <div class="indent-box">
                                <img alt="" src="images/6page_title1.gif" class="title1" /><br />
                                <div class="h1"><input type="text" class="input1" value="Name:  " /></div>
                                <div class="h1"><input type="text" class="input1" value="E-Mail: " /></div>
                                <div class="h1"><input type="text" class="input1" value="Phone:" /></div>
                                <div class="h1"><input type="text" class="input1" value="State:" /></div>
                                <textarea rows="40" class="textarea" cols="30" value="Message:">Message:</textarea><br />
                                <div class="fright"> <a href="#" class="link-1" onclick="document.getElementById('form2').reset()"><em><b>Reset</b></em></a>
                                     <div class="indent-2"><a href="#" class="link-1" onclick="document.getElementById('form2').submit()"><em><b>Send</b></em></a></div>
                                </div>
                                <div class="clear"></div>
                            </div>
                            </form>
                        </div>

 

so lets say i make a contact.php and i will change it to <form action="contact.php" id="form2">

 

how about this line: what should i replace with "a href?????? "

 <div class="fright"> <a href="#" class="link-1" onclick="document.getElementById('form2').reset()"><em><b>Reset</b></em></a>
                                     <div class="indent-2"><a href="#" class="link-1" onclick="document.getElementById('form2').submit()"><em><b>Send</b></em></a></div>

 

 

and here is my contact.php page... it doesn't work properly

<?php

$name = $_POST['Name'];
$email = $_POST['E-Mail'];
$phone = $_POST['Phone'];
$state = $_POST['State'];

$Message = $_POST['Message'];

$to = "[email protected]";

$subject;

$message = "";
foreach($_POST as $key=>$value)
{
$message .= $key.": ".$value."\n\r";
}

mail($to,$subject,$message);

?>

<html>
<head> <title> Contact - Message Sent</title>
<body>

Message Sent Succesfully.

</body>
</html>

 

thanks ~

Link to comment
https://forums.phpfreaks.com/topic/175051-template-contact-form-help/
Share on other sites

Subject is not defined.. well you need to make it defined with what you want anyways.

<?php
$subject = 'Now the email has a subject'; // edit with own subject line

 

next, blank message case sensitive perhaps!

<?php

$message = $_POST['Message']."\r\n"; // change to lowercase and remove $message='';
//$message = ""; remove this, now the message will be in the email before the other details of the contact form

 

 

want a from? add headers.

<?php
$headers  = "From: ".$name."<".$email.">\r\n";

mail($to,$subject,$message,$headers); // add $headers into mail function

?>

Subject is not defined.. well you need to make it defined with what you want anyways.

<?php
$subject = 'Now the email has a subject'; // edit with own subject line

 

next, blank message case sensitive perhaps!

<?php

$message = $_POST['Message']."\r\n"; // change to lowercase and remove $message='';
//$message = ""; remove this, now the message will be in the email before the other details of the contact form

 

 

want a from? add headers.

<?php
$headers  = "From: ".$name."<".$email.">\r\n";

mail($to,$subject,$message,$headers); // add $headers into mail function

?>

 

it is getting better, it appears on my mail box now... but i still dont see any message

this is what it looks like

From Nobody <[email protected]>

to [email protected]

date Tue, Sep 22, 2009 at 6:10 PM

subject Tour

 

and here is the code for the contact.php

<?php
$headers  = "From: ".$name."<".$email.">\r\n";

mail($to,$subject,$message,$headers); 

$subject = 'Tour'; 
$name = $_POST['Name'];
$email = $_POST['E-Mail'];
$phone = $_POST['Phone'];
$state = $_POST['State'];


$message = $_POST['Message']."\r\n"; 


$to = "[email protected]";

$subject;


foreach($_POST as $key=>$value)
{
$message .= $key.": ".$value."\n\r";
}

mail($to,$subject,$message);

?>

<html>
<head> <title> Contact - Message Sent</title>
<body>

Message Sent Succesfully.

</body>
</html>

 

 

and my html code

<div id="content">      
        <div class="bg-cont png">
            <div class="indent-main">
                <div class="container">
                    <div class="col-1">
                        <div class="box">
                             <form action="contact.php" method="POST" id="form2">
                            <div class="indent-box">
                                <img alt="" src="images/6page_title1.gif" class="title1" /><br />
                                <div class="h1"><input type="text" class="input1" value="Name:  " /></div>
                                <div class="h1"><input type="text" class="input1" value="E-Mail: " /></div>
                                <div class="h1"><input type="text" class="input1" value="Phone:" /></div>
                                <div class="h1"><input type="text" class="input1" value="State:" /></div>
                                <textarea rows="40" class="textarea" cols="30" value="Message:">Message:</textarea><br />
							<input type="reset" value="reset" />
<input type="submit" value="submit" />
                               
                                <div class="clear"></div>
                            </div>
                            </form>
                        </div>

 

thanks alot man  :'(

<?php
$subject = 'Tour'; 
$name = $_POST['Name'];
$email = $_POST['E-Mail'];
$phone = $_POST['Phone'];
$state = $_POST['State'];

$message = "Name: $name\r\n";
$message.= "Email: $email\r\n";
$message.= "Phone: ".$_POST['Phone']."\r\n";
$message.= "State: ".$_POST['State']."\r\n";
$message.= "Message: ".$_POST['Message']."\r\n";

$to = "[email protected]";

$headers = "From: ".$name."<".$email.">\r\n";

if(!mail($to,$subject,$message,$headers)){
$err = 'Message Not Sent.';
}else{
$err = 'Message Sent Succesfully.';
}

?>

<html>
<head> <title> Contact - Message Sent</title>
<body>
<?php
echo $err;
?>
</body>
</html>

<?php
$subject = 'Tour'; 
$name = $_POST['Name'];
$email = $_POST['E-Mail'];
$phone = $_POST['Phone'];
$state = $_POST['State'];

$message = "Name: $name\r\n";
$message.= "Email: $email\r\n";
$message.= "Phone: ".$_POST['Phone']."\r\n";
$message.= "State: ".$_POST['State']."\r\n";
$message.= "Message: ".$_POST['Message']."\r\n";

$to = "[email protected]";

$headers = "From: ".$name."<".$email.">\r\n";

if(!mail($to,$subject,$message,$headers)){
$err = 'Message Not Sent.';
}else{
$err = 'Message Sent Succesfully.';
}

?>

<html>
<head> <title> Contact - Message Sent</title>
<body>
<?php
echo $err;
?>
</body>
</html>

 

its getting better  :D

 

but when i check my email  :wtf: geeez i am still researching ... man it is hard :(

 

from

to [email protected]

date Tue, Sep 22, 2009 at 6:40 PM

subject Tour

 

hide details 6:40 PM (0 minutes ago)

 

 

Name:

Email:

Phone:

State:

Message:

ermmm, sorry for not seeing this before, I will let you add this (some homework ;))

 

no names given to form fields....

<div id="content">     
        <div class="bg-cont png">
            <div class="indent-main">
                <div class="container">
                    <div class="col-1">
                        <div class="box">
                             <form action="contact.php" method="POST" id="form2">
                            <div class="indent-box">
                                <img alt="" src="images/6page_title1.gif" class="title1" /><br />
                                <div class="h1"><input type="text" class="input1" name="Name" value="Name:  " /></div>
                                <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div>
                                <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div>
                                <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div>
                                <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br />
                        <input type="reset" value="reset" />
<input type="submit" value="submit" />
                               
                                <div class="clear"></div>
                            </div>
                            </form>
                        </div>

ermmm, sorry for not seeing this before, I will let you add this (some homework ;))

 

no names given to form fields....

<div id="content">     
        <div class="bg-cont png">
            <div class="indent-main">
                <div class="container">
                    <div class="col-1">
                        <div class="box">
                             <form action="contact.php" method="POST" id="form2">
                            <div class="indent-box">
                                <img alt="" src="images/6page_title1.gif" class="title1" /><br />
                                <div class="h1"><input type="text" class="input1" name="Name" value="Name:  " /></div>
                                <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div>
                                <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div>
                                <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div>
                                <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br />
                        <input type="reset" value="reset" />
<input type="submit" value="submit" />
                               
                                <div class="clear"></div>
                            </div>
                            </form>
                        </div>

 

i did muck around with it before, is it to do with name=""? and i just add them myself before they only have

 <div class="h1"><input type="text" class="input1" value="Name:  " /></div>

 

this is what they look like before :S

or

textarea rows="40" class="textarea" cols="30" >Message:</textarea><br />

 

u make my day!! thanks man ... it works, i will try some more  8) !! another thanks for u _b

ermmm, sorry for not seeing this before, I will let you add this (some homework ;))

 

no names given to form fields....

<div id="content">     
        <div class="bg-cont png">
            <div class="indent-main">
                <div class="container">
                    <div class="col-1">
                        <div class="box">
                             <form action="contact.php" method="POST" id="form2">
                            <div class="indent-box">
                                <img alt="" src="images/6page_title1.gif" class="title1" /><br />
                                <div class="h1"><input type="text" class="input1" name="Name" value="Name:  " /></div>
                                <div class="h1"><input type="text" class="input1" name="E-Mail" value="E-Mail: " /></div>
                                <div class="h1"><input type="text" class="input1" name="Phone" value="Phone:" /></div>
                                <div class="h1"><input type="text" class="input1" name="State" value="State:" /></div>
                                <textarea rows="40" class="textarea" cols="30" name="Message">Message:</textarea><br />
                        <input type="reset" value="reset" />
<input type="submit" value="submit" />
                               
                                <div class="clear"></div>
                            </div>
                            </form>
                        </div>

value="" with inputs will make that the value, the actual data in the field itself.

 

with textarea, the value is the data within <textarea> this is the data which is the value </textarea>

 

name="" is what is used when 'identifying', the key, of each value. (I am no good at explaining  :-[)

 

so where <input type=text" name="email" value="[email protected]" /> or what value is entered by the user

 

you would retrieve it on your process form with $email = $_POST['email]; <-- where ['this value=the name of the field'], assuming the method used in the form was method="POST"

 

I stop now, I confusing me  ::)

value="" with inputs will make that the value, the actual data in the field itself.

 

with textarea, the value is the data within <textarea> this is the data which is the value </textarea>

 

name="" is what is used when 'identifying', the key, of each value. (I am no good at explaining  :-[)

 

so where <input type=text" name="email" value="[email protected]" /> or what value is entered by the user

 

you would retrieve it on your process form with $email = $_POST['email]; <-- where ['this value=the name of the field'], assuming the method used in the form was method="POST"

 

I stop now, I confusing me  ::)

 

nah, it is all good, i learnt alot from ya.

 

ok now i figure some problem....

 

i recievied the email fine and works well

 

but i click reply it shows [email protected] Name: 222asdsa <E-Mail:> as in fulll

 

i try modify

$headers = "From: ".$name."<".$email.">\r\n";

 

to

$headers = "From: ".$email."\r\n";

 

is that right?

 

and i wana modify the

  $err = 'Message Sent Succesfully.';

do i just do it from there. i mean make the text go mid and insert a picture etc

 

thanks~

i try modify

$headers = "From: ".$name."<".$email.">\r\n";

 

to

$headers = "From: ".$email."\r\n";

 

is that right?

 

Yes

 

 

and i wana modify the

  $err = 'Message Sent Succesfully.';

do i just do it from there. i mean make the text go mid and insert a picture etc

 

You can output any html or text in $err

eg:

$err='<p class="message"><img src="mailsent.jpg" alt="Email Sent" /></p>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.