Free Web Hosting Forum
(#51 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 424
Join Date: Jun 2008
Send a message via AIM to Red-X
Default My contact form - 06-21-2008, 02:25 PM

Here's a contact form I made. If you have any problems ask me.

Create a HTML or PHP file called contact. with this...

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>THE TITLE OF YOUR CONTACT FORM</title>
</head>
<body>
<form action="mail.php" method="post" name="mail">
<font color="#000000">Name:</font><br>
<input name="name" type="text" size="50" maxlength="50" /><br>
<font color="#000000">E-mail:</font><br>
<input name="email" type="text" size="50" maxlength="50" /><br>
<font color="#000000">Subject:</font><br>
<select name="subject">
<option value="Please select a topic....." selected="selected">Please select a topic.....</option>
<option value="Leave a comment">Leave a comment</option> 
<option value="Report a site problem">Report a site problem</option>
<option value="Ask a question">Ask a question</option>
<option value="Other (please explain below)">Other (please explain below)</option></select><br>
<font color="#000000">Comment:</font><br>
<textarea name="comment" cols="50" rows="10"></textarea><br>
<input type="checkbox" name="copy"><font size="2">Send me a copy of the email.</font><br><p></p>
<input name="submit" type="submit" value="Send" /><input name="reset" type="reset" />
</form>
</body>
</html>
create a PHP file called mail.php

PHP Code:
<?php
//Variables.
$user_email $_REQUEST['email'];
$user_name $_REQUEST['name'];
$user_subject $_REQUEST['subject'];
$user_comment $_REQUEST['comment'];
$user_send $_REQUEST['copy'];
$user_check stripos("$user_email","@");
//Body of the email to be sent.
$body_mail "Hello YOURANME, someone wants to contact you.. Details.. 
Name: $user_name $user_lastname 
Email: $user_email 
subject: $user_subject
Comment: $user_comment."
;
//Body of the Email for the user requesting a copy.
$body_email "
Here is a copy of the email.
Your Name: $user_name $user_lastname.
Your Email: $user_email. 
Your subject: $user_subject.
Your Comment: $user_comment.
Thank you for contacting us, we'll reply ASAP.
Yourwebsite team."
;
//Check if the user submited the data require.
//If the @ is measing from the email address stop the user for continuing.
if ($user_check) {
echo 
"";
}
else {
echo 
"You can't continue with out a email address, Please enter a email address.";
   exit (
$user_check);
}
if (empty(
$user_name)) {
echo 
"<center><h2><font color='ff0000'>ERROR</font></h2></center>You didn't enter a your first name.<br>";
   exit();
}
elseif (!
$user_comment) {
echo 
"<center><h2><font color='ff0000'>ERROR</h2></center></font>Please enter a comment.";
   die();
}
//Everything okay? send the e-mail.     
else {
mail('YOUREMAIL','Email from YOURWEBITE',"$body_mail","from:YOURWEBSITE");
    echo 
"your email was sent! Thank you.";
}
//If the checkbox if check send a copy to the user.
if (isset($user_send)) {
@
mail("$user_email","The copy of your information from YOURWEBSITE","$body_email","YOURWEBSITE");
    echo 
"And a copy of the Email was send to you!";
}
else {
     die(
$user_send);
}
?>
You have to change where it says YOUREMAIL, YOURNAME etc.
Reply With Quote
Sponsored Links
(#52 (permalink))
Old
Member
Heza is on a distinguished road
 
Posts: 38
Join Date: Jun 2008
Default 06-21-2008, 09:33 PM

Quote:
Originally Posted by Red-X View Post
@Heza I don't know much about databases but can you post your table so I can see it?
I dont think there is a way of doing that but the table has the same fields as in my code and correct extra data to go along with it
Reply With Quote
(#53 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 424
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 06-21-2008, 09:40 PM

That's weird, do you have a file called something.sql?
Reply With Quote
(#54 (permalink))
Old
Member
Heza is on a distinguished road
 
Posts: 38
Join Date: Jun 2008
Default 06-21-2008, 11:08 PM

no i dont
?
Reply With Quote
(#55 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 424
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 06-21-2008, 11:15 PM

You have to have a table for the username, password, age etc. It should look something like this.....


Code:
#
#  Table structure for users table
#
DROP TABLE IF EXISTS users;

CREATE TABLE users (
 username varchar(30) primary key,
 password varchar(32),
 userid varchar(32),
 userlevel tinyint(1) unsigned not null,
 email varchar(50),
 timestamp int(11) unsigned not null
);
Reply With Quote
(#56 (permalink))
Old
Member
Heza is on a distinguished road
 
Posts: 38
Join Date: Jun 2008
Default 06-21-2008, 11:22 PM

i know i do
Reply With Quote
(#57 (permalink))
Old
Member
Heza is on a distinguished road
 
Posts: 38
Join Date: Jun 2008
Default 06-21-2008, 11:22 PM

thats what i was talking about when i meant database
Reply With Quote
(#58 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 424
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 06-21-2008, 11:24 PM

Right I don't know much about database tables but post yours here so I can see it.
Reply With Quote
(#59 (permalink))
Old
Member
Heza is on a distinguished road
 
Posts: 38
Join Date: Jun 2008
Default 06-21-2008, 11:32 PM

-- Table structure for table `users`
--

CREATE TABLE `users` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(32) collate latin1_general_ci NOT NULL,
`password` varchar(32) collate latin1_general_ci NOT NULL,
`email` varchar(255) collate latin1_general_ci NOT NULL,
`name` varchar(64) collate latin1_general_ci NOT NULL,
`age` int(2) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ;
Reply With Quote
(#60 (permalink))
Old
Red-X's Avatar
Senior Member
Red-X is on a distinguished road
 
Posts: 424
Join Date: Jun 2008
Send a message via AIM to Red-X
Default 06-21-2008, 11:43 PM

And you can create the table without any errors?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com