PDA

View Full Version : PHP Contact Form,



x-glow
13-06-2009, 08:00 PM
Ok, so I need a code for my site so people can contact me via email through the form if ya get me, does anyone have the code? PLEASE!

scottish
13-06-2009, 08:05 PM
http://www.w3schools.com/php/php_mail.asp

What beats learning to do it?

Jam-ez
13-06-2009, 08:06 PM
http://www.habboxforum.com/showpost.php?p=5835880&postcount=5

PM me if you need any help with any of the code or anything.

x-glow
13-06-2009, 08:14 PM
Sorry that one dosent work mas there is no where to put your email :( and for the w3 schools it dosent properly explain what im looking for ;)

scottish
13-06-2009, 08:16 PM
we don't know exactly what your looking for;

what we know is;
Its a PHP email form
It has to email you
....

I fail to see how it doesn't do what you need it to do?

Jam-ez
13-06-2009, 08:23 PM
What...? I don't understand either "there is no where to put your email", do you mean the users email - or your email?

x-glow
13-06-2009, 08:39 PM
Right IF YOU CAN READ it Says orry that one dosent work mas there is no where to put your email THAT WAS THE OTHER GUYS POST IF U READ!! And Im looking for a CONTACT US PHP Code for my Website..

lick
13-06-2009, 08:42 PM
emailmeform.com

best one tbh, creat an account and then just put the html code on ur site

Jam-ez
13-06-2009, 09:00 PM
Right IF YOU CAN READ it Says orry that one dosent work mas there is no where to put your email THAT WAS THE OTHER GUYS POST IF U READ!! And Im looking for a CONTACT US PHP Code for my Website..

What I gave you was a contact form. If you can't edit that to your liking you mayswell give up now...

Edit: Actually no, I can hardly read what you said.

Unloyal
15-06-2009, 09:38 PM
Extremley simple...

Contact.php
---------------


<form method="post" action="Mail.php">
<?
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="name" size="35" />
<br />
Your Email:<br />
<input type="text" name="email" size="35" />
<br /> <br />
<br />
Why you contacted us:<br />
<select name="attn" size="1">
<option value="General">General Feedback</option>
<option value="Technical Support">Technical Support</option>
<option value="Job Application">Job Application</option>
<option value="Compliment">Compliment</option>
<option value="Complaint">Complaint</option>
</select>
<br /><br />
Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send" />
</form>


Mail.php


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['name'];
$visitormail = $_POST['email'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];

// Stops someone attempting to do a simple inclusion hack.
if (eregi('http:', $notes)) {
die ("Lol you fail.");
}
// End inclusion hack block
// ------------------------------------------
// Stops someone from entering an invalid email
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Enter a valid e-mail</h2>\n";
$badinput = "<h2>Email was not sent!</h2>\n";
echo $badinput;
die ("Go back!");
}

// End Email validation
// ------------------------------------------
// Makes sure all fields are filled in

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Please fill in all fields</h2>\n";
die ("Use back!");
}

// End inclusion hack block
// ------------------------------------------
// Gathers the information to be said in the email.

$todayis = date("F j, Y, g:i a");;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
-------------------------------------- \n
Attention: $attn \n
-------------------------------------- \n
Message: \n
$notes \n
-------------------------------------- \n
From: $visitor ($visitormail)\n
-------------------------------------- \n
Additional Info: \n
-------------------------------------- \n
IP = $ip \n
-------------------------------------- \n
Browser Info: $httpagent \n
-------------------------------------- \n
Referral : $httpref \n
-------------------------------------- \n
";

$from = "From: $visitormail\r\n";

// End email info
// ------------------------------------------
// Sends off the email.

mail("YOUR_EMAIL_HERE", $subject, $message, $from);
?>


All you have to do is edit the options on Contact.php and put your email in Mail.php

Simple.

x-glow
16-06-2009, 05:20 PM
Thank You So Much! +rep to you !

Protege
16-06-2009, 05:51 PM
That is so crap, you should -rep yourself now.


echo "<h2>Enter a valid e-mail</h2>\n";
$badinput = "<h2>Email was not sent!</h2>\n";
echo $badinput;
die ("Go back!");So when that is processed that will equal on the page[/PHP]

Enter a valid e-mail
Email was not sent!
Go back!

Would it not be easier to go


echo "no valid email\nemail wasnt sent duh?\ngo back";

Dont get me started about all of it please...


Extremley simple...

Contact.php
---------------


<form method="post" action="Mail.php">
<?
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Your Name: <br />
<input type="text" name="name" size="35" />
<br />
Your Email:<br />
<input type="text" name="email" size="35" />
<br /> <br />
<br />
Why you contacted us:<br />
<select name="attn" size="1">
<option value="General">General Feedback</option>
<option value="Technical Support">Technical Support</option>
<option value="Job Application">Job Application</option>
<option value="Compliment">Compliment</option>
<option value="Complaint">Complaint</option>
</select>
<br /><br />
Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send" />
</form>
Mail.php


<?php

$ip = $_POST['ip'];
$httpref = $_POST['httpref'];
$httpagent = $_POST['httpagent'];
$visitor = $_POST['name'];
$visitormail = $_POST['email'];
$notes = $_POST['notes'];
$attn = $_POST['attn'];

// Stops someone attempting to do a simple inclusion hack.
if (eregi('http:', $notes)) {
die ("Lol you fail.");
}
// End inclusion hack block
// ------------------------------------------
// Stops someone from entering an invalid email
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
{
echo "<h2>Enter a valid e-mail</h2>\n";
$badinput = "<h2>Email was not sent!</h2>\n";
echo $badinput;
die ("Go back!");
}

// End Email validation
// ------------------------------------------
// Makes sure all fields are filled in

if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Please fill in all fields</h2>\n";
die ("Use back!");
}

// End inclusion hack block
// ------------------------------------------
// Gathers the information to be said in the email.

$todayis = date("F j, Y, g:i a");;

$attn = $attn ;
$subject = $attn;

$notes = stripcslashes($notes);

$message = " $todayis [EST] \n
-------------------------------------- \n
Attention: $attn \n
-------------------------------------- \n
Message: \n
$notes \n
-------------------------------------- \n
From: $visitor ($visitormail)\n
-------------------------------------- \n
Additional Info: \n
-------------------------------------- \n
IP = $ip \n
-------------------------------------- \n
Browser Info: $httpagent \n
-------------------------------------- \n
Referral : $httpref \n
-------------------------------------- \n
";

$from = "From: $visitormail\r\n";

// End email info
// ------------------------------------------
// Sends off the email.

mail("YOUR_EMAIL_HERE", $subject, $message, $from);
?>
All you have to do is edit the options on Contact.php and put your email in Mail.php

Simple.

Jam-ez
16-06-2009, 06:09 PM
Isn't that exactly what I gave him/her? The minds of small children...

x-glow
16-06-2009, 07:06 PM
Isn't that exactly what I gave him/her? The minds of small children...


Maybe b u yurs didnt have EMAIL HERE LOL!

x-glow
16-06-2009, 07:07 PM
That is so crap, you should -rep yourself now.


echo "<h2>Enter a valid e-mail</h2>\n";
$badinput = "<h2>Email was not sent!</h2>\n";
echo $badinput;
die ("Go back!");So when that is processed that will equal on the page[/PHP]

Enter a valid e-mail
Email was not sent!
Go back!

Would it not be easier to go


Edited by Catzsy [Forum Super Moderator]: Please do not double post within the 15 minute editing period. Thanks.


echo "no valid email\nemail wasnt sent duh?\ngo back";Dont get me started about all of it please...

Also Ok diss him? But you cant IF U CANT EVEN CODE ONE!

scottish
16-06-2009, 07:18 PM
You're dissing him and your the one who completely failed at it, two people gave you a sufficient one and you didn't have a clue so so don't insult someone else when you can't do nothing for yourself.

thanks ;)

x-glow
16-06-2009, 07:26 PM
Well I cnt exacaly say ur post did the trick?

scottish
16-06-2009, 07:29 PM
If you read it you'd understand it instead of being so lazy as to need the EXACT code posted.

When someone gives you the exact code it is COMPLETELY useless as you're not going to learn nothing but to leech/copy and paste...

It's not exactly rocket science. :rolleyes:

Unloyal
16-06-2009, 08:45 PM
That is so crap, you should -rep yourself now.


echo "<h2>Enter a valid e-mail</h2>\n";
$badinput = "<h2>Email was not sent!</h2>\n";
echo $badinput;
die ("Go back!");So when that is processed that will equal on the page[/PHP]

Enter a valid e-mail
Email was not sent!
Go back!

Would it not be easier to go


echo "no valid email\nemail wasnt sent duh?\ngo back";Dont get me started about all of it please...
It may not be the most efficient code in the world, but it does the job.

The OP did not say that the code itself has to be efficient; so please, aslong as it works - get off my back.

Jam-ez
16-06-2009, 08:48 PM
Maybe b u yurs didnt have EMAIL HERE LOL!

Actually.. it did:


Sheesh, if only Dreamweaver loaded faster.
No idea if this will work. Quickly mopped it up.

PHP Code:

<?php

// begin switch statement!
switch ( $_GET['mail'] )
{

default:

// Begin displaying "THE BOX!"
echo( "<form method='post' action='?mail=1'>" );
echo( "Email: <input type='text' name='email' size='20' />" );
echo( "<br /><br />" );
echo( "Full Name: <input type='text' name='full_name' size='20' />" );
echo( "<br /><br />" );
echo( "Comments: <input type='text' name='comments' size='20' />" );
echo( "<br /><br />" );
echo( "<input type='submit' name='submit' value='Submit!' />" );
echo( "<br /><br />" );
echo( "</form>" );

break;

// start secondary case/executed case
case '1':

if ( (!isset( $_POST['email'] )) || (!isset( $_POST['full_name'] )) || (!isset( $_POST['comments'] )) )
{

die( "Please try again... you didn't submit all the data!" );

}

$ip = $_SERVER['REMOTE_ADDR'];
$email_address = $_POST['email'];
$email_name = $_POST['full_name'];
$email_comment = $_POST['comments'];
$your_email = 'youremailgoeshere1111';
$email_subject = 'Mail Form.';
$message_headers = 'From: ' . $your_email . '\r\nReply-To: ' . $your_email . '\r\n X-Mailer: PHP: ' . phpversion();

$email_full = 'Message from: ' . $email_name . ' at ' . $email_address . '<br /><br />Comment: ' . $email_comment . '<br /><br />Sent from your mailing system!';

mail( $your_email, $email_subject, $email_full, $message_headers );

break;

}

?>

Edit: All you have to do is change your email, $your_email = 'youremailgoeshere1111'; and it should work.
Feel free to change it in anyway, or use it anyway!

Protege
17-06-2009, 05:39 PM
Also Ok diss him? But you cant IF U CANT EVEN CODE ONE!

loled hard man

BoyBetterKnow
25-06-2009, 08:33 AM
Naa Protege can code lmao.

And yeh that contact form aint great but at least the guy tried to help ;)

Want to hide these adverts? Register an account for free!