PDA

View Full Version : Contact Form Code



Sam
17-09-2005, 12:23 PM
Simple Code For A Contact Form :P I Can Make 100's Of other things too lmao

Simple copy n Paste this code into the content box on your site, Replacing the [email protected] with the email you want the form to be sent to :P


<?php
//Support for this script found at http://www.habbo-twice.co.uk/ at the forums area.
//Variables - Your e-mail address (keep this file name : contact.php)
$your_email = "[email protected]";

//Show Mail Form
function showForm() {
echo "<html><head>\n"
."<title>Contact Us</title>\n"
."</head><body>\n"
."<font face='arial' size='2'>\n"
."<h1>Contact Us</h1>\n"
."<form method='post' action='contact.php?action=sendEmail'>\n"
."<table width='100%' border='0' cellspacing='0' cellpadding='4'>\n"
."<tr>\n"
."<td width='25%'><font face='arial' size='2'>Your Name:</font></td>\n"
."<td width='75%'><input type='text' name='name' size='40'></td>\n"
."</tr><tr>\n"
."<td width='25%'><font face='arial' size='2'>Your Email:</font></td>\n"
."<td width='75%'><input type='text' name='email' size='40'></td>\n"
."</tr><tr>\n"
."<td width='25%'><font face='arial' size='2'>Subject:</font></td>\n"
."<td width='75%'><input type='text' name='subject' size='40'></td>\n"
."</tr><tr>\n"
."<td width='25%'><font face='arial' size='2'>Message:</font></td>\n"
."<td width='75%'><textarea name='message' rows='10' cols='35'></textarea></td>\n"
."</tr></table>\n"
."<input type='submit' value='Send'>\n"
."</form></body></html>\n";
}

//Send Email
function sendEmail() {
global $your_email,$name,$email,$subject,$message;
if ( !$name | !$email | !$subject | !$message ) {
header ("Location: contact.php");
}
else {
$email2 = "$email ($name)";
mail( $your_email, $subject, $message, "From: $email2");
echo "<html><head>\n"
."<title>Email Sent!</title>\n"
."</head><body>\n"
."<font face='arial' size='2'>\n"
."<h1>Email Sent!</h1>\n"
."Your Email has been sent with success!\n"
."</font></body></html>\n";
}
}

//Switch Statement
Switch ( $action ) {

Case 'sendEmail':
sendEmail();
Break;

Default:
showForm();

}

?>

icebox12
17-09-2005, 12:25 PM
Havn't tried yet so I cannot give a rating good work though I'll test it in a moment :)

Sam
17-09-2005, 12:27 PM
Ty :D :P Its the one i used on my site, But its Closed Now

icebox12
17-09-2005, 12:51 PM
Ok the script here has worked perfectly...

Well done, great work +rep

Keep up the good work :)

--
Regards

Mentor
17-09-2005, 01:01 PM
pretty basic "/ plus not realy helpful if people want to be able to customize there form, athogh then again, they could use my tutoral for that along with a little more work "/

Sam
17-09-2005, 01:06 PM
<?php
//Support for this script found at http://www.habbotwice.co.uk/ at the forums area.
//Variables - Your e-mail address (keep this file name : contact.php)
$your_email = "eggsnbacon_01********.co.uk";

//Show Mail Form
function showForm() {
echo "<html><head>\n"
."<title>Contact Us</title>\n"
."</head><body>\n"
."<font face='arial' size='2'>\n"
."<h1>Contact Us</h1>\n"
."<form method='post' action='contact.php?action=sendEmail'>\n"
."<table width='100%' border='0' cellspacing='0' cellpadding='4'>\n"
."<tr>\n"
."<td width='25%'><font face='arial' size='2'>Your Name:</font></td>\n"
."<td width='75%'><input type='text' name='name' size='40'></td>\n"
."</tr><tr>\n"
."<td width='25%'><font face='arial' size='2'>Your Email:</font></td>\n"
."<td width='75%'><input type='text' name='email' size='40'></td>\n"
."</tr><tr>\n"
."<td width='25%'><font face='arial' size='2'>Subject:</font></td>\n"
."<td width='75%'><input type='text' name='subject' size='40'></td>\n"
."</tr><tr>\n"
."<select name="rate">
<option>5</option>
<option>4</option>
<option>3</option>
<option>2</option>
<option>1</option>
</select>

."<td width='25%'><font face='arial' size='2'>Message:</font></td>\n"
."<td width='75%'><textarea name='message' rows='10' cols='35'></textarea></td>\n"
."</tr></table>\n"
."<input type='submit' value='Send'>\n"
."</form></body></html>\n";
}

//Send Email
function sendEmail() {
global $your_email,$name,$email,$subject,$message,$rate;
if ( !$name | !$email | !$subject | !$message | !$rate ) {
header ("Location: contact.php");
}
else {
$email2 = "$email ($name)";
mail( $your_email, $subject, $message, "From: $email2");
echo "<html><head>\n"
."<title>Email Sent!</title>\n"
."</head><body>\n"
."<font face='arial' size='2'>\n"
."<h1>Email Sent!</h1>\n"
."Your Email has been sent with success!\n"
."</font></body></html>\n";
}
}

//Switch Statement
Switch ( $action ) {

Case 'sendEmail':
sendEmail();
Break;

Default:
showForm();

}

?>


</body>
</html>

Tell Me if The Site Rating Bit Works On That ''/ I'll Mod It innamin Its Just I My sites cPanel Is dwn so i cnt test it

icebox12
17-09-2005, 01:26 PM
Error occured:-

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home2/habbling/public_html/contact.php on line 43

Sam
17-09-2005, 01:27 PM
Hmm, I'LL Mod it Innamin

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