View previous topic :: View next topic |
Author |
Message |
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Wed Jul 05, 2006 4:07 pm Post subject: Help creating a simple contact form for my site |
|
|
Hello community,
Could someone please give me a hand creating the worlds first dumb person understandable simplest contact form ever :P
I tried several scripts but I'm yet to experiance luck in any situation..
As most of you would know, this is my site at http://www.mrwiseone.com/ .
Any help or suggestions would be greatly appreciated for both the site and the script,
Regards Tom |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Wed Jul 05, 2006 4:16 pm Post subject: |
|
|
What fields do you want the form to ask?
What type of reponse should it be requesting (e.g. text input, radio buttons, drop down boxes)?
Do you want the forms submission to be dropped into MySQL or emailed to you? _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Wed Jul 05, 2006 4:20 pm Post subject: |
|
|
Dropped into mysql? You appear to be willing to spend some time on this. MySql would be great but it only had to be simple :o
But since you offered me I will take you up on it if you have the time. I might just have to install MySql anyway!
PS I may have sent you a PM earlier.. I also may have misseen you for another person and in saying this lucky I wasn't having a go at this person... xD |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Wed Jul 05, 2006 4:41 pm Post subject: |
|
|
This is pretty much as simple as I can get. It just dumps the forms contents into the Database whos name you supply. First Page is an example of the Form:
Code: | <form action="./add_user.php" method="POST">
Name:<input type="text" name="name" size="40">
Email Address:<input type="text" name="email" size="40">
<input type="submit" value="Submit">
</form> |
And then the Contents of add_user.php:
Code: | <?php
$email = $_POST['email'];
$name = $_POST['name'];
$connection = mysql_connect("SERVER_HOST","SERVER_USER","SERVER_PASSWORD")
or die("Could not connect to the MySQL Database");
$db = mysql_select_db('DATABASE_NAME', $connection)
or die("Could not select the MySQL Database");
$query = "INSERT INTO login (email, name) VALUES ('$email', '$name')";
$result = mysql_query($query)
or die("Query Failed: " . mysql_error());
?> |
For each new form input you add, you must add a:
Code: | $name = $_POST['name']; |
with the Input's name ($_POST['name']) and what you want PHP to call it ($name). AND THEN you must add the PHP name && which column you want it inserted into in the MySQL query, which also means that if you add a new input, you will have to add that column name into your MySQL table. Sounds confusing eh? lol. So basically, if you add a new input called "HAHA" your code will look something like this:
Code: | <form action="./add_user.php" method="POST">
Name:<input type="text" name="name" size="40">
Email Address:<input type="text" name="email" size="40">
HAHA:<input type="text" name="HAHA" size="40">
<input type="submit" value="Submit">
</form> |
Code: | <?php
$email = $_POST['email'];
$name = $_POST['name'];
$HAHA = $_POST['HAHA'];
$connection = mysql_connect("SERVER_HOST","SERVER_USER","SERVER_PASSWORD")
or die("Could not connect to the MySQL Database");
$db = mysql_select_db('DATABASE_NAME', $connection)
or die("Could not select the MySQL Database");
$query = "INSERT INTO login (email, name, HAHA) VALUES ('$email', '$name', '$HAHA')";
$result = mysql_query($query)
or die("Query Failed: " . mysql_error());
?> |
Any questions? :D :lol: _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Wed Jul 05, 2006 7:22 pm Post subject: |
|
|
Didn't you forget to escape the data?
Last edited by cmxflash on Thu Jul 06, 2006 5:46 am; edited 1 time in total |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Wed Jul 05, 2006 7:28 pm Post subject: |
|
|
For somebody who hates the person that's going to use it, that's a pretty dumb thing to say. _________________
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jul 06, 2006 5:29 am Post subject: |
|
|
MonkeyNation wrote: | For somebody who hates the person that's going to use it, that's a pretty dumb thing to say. |
Dear MonkeyNation, your a small man and you can't just leave the past behind.
That is all.
0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
As for eveyone else trying to help thanks alot and as we say in Japanese, arigatou gozaimasu |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Thu Jul 06, 2006 6:10 am Post subject: |
|
|
That is all. =] (I'm sorry, I had to lol) _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Jul 06, 2006 6:44 am Post subject: |
|
|
MrWiseOne wrote: | Dear MonkeyNation, your a small man and you can't just leave the past behind.
That is all.
0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
As for eveyone else trying to help thanks alot and as we say in Japanese, arigatou gozaimasu |
What?
I wasn't talking to you, you idiot. It was by all means the right thing to do, just dumb considering the situation.
Now if you're quite done with your hissy fit, you can shut up. _________________
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jul 06, 2006 7:28 am Post subject: |
|
|
MonkeyNation wrote: | MrWiseOne wrote: | Dear MonkeyNation, your a small man and you can't just leave the past behind.
That is all.
0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
As for eveyone else trying to help thanks alot and as we say in Japanese, arigatou gozaimasu |
What?
I wasn't talking to you, you idiot. It was by all means the right thing to do, just dumb considering the situation.
Now if you're quite done with your hissy fit, you can shut up. |
Grow up.
Could we please progress with this now? :wink: |
|
Back to top |
|
|
AbyssUnderground -
Joined: 31 Dec 2004 Posts: 3855
|
Posted: Thu Jul 06, 2006 8:08 am Post subject: |
|
|
MrWiseOne wrote: | MonkeyNation wrote: | MrWiseOne wrote: | Dear MonkeyNation, your a small man and you can't just leave the past behind.
That is all.
0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
As for eveyone else trying to help thanks alot and as we say in Japanese, arigatou gozaimasu |
What?
I wasn't talking to you, you idiot. It was by all means the right thing to do, just dumb considering the situation.
Now if you're quite done with your hissy fit, you can shut up. |
Grow up.
Could we please progress with this now? :wink: |
If you talked sense people would get on with it. And I think youll find MN is a little more mature and grown up than you are. _________________ Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jul 06, 2006 8:36 am Post subject: |
|
|
The Inquisitor wrote: | MrWiseOne wrote: | MonkeyNation wrote: | MrWiseOne wrote: | Dear MonkeyNation, your a small man and you can't just leave the past behind.
That is all.
0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0-0
As for eveyone else trying to help thanks alot and as we say in Japanese, arigatou gozaimasu |
What?
I wasn't talking to you, you idiot. It was by all means the right thing to do, just dumb considering the situation.
Now if you're quite done with your hissy fit, you can shut up. |
Grow up.
Could we please progress with this now? :wink: |
If you talked sense people would get on with it. And I think youll find MN is a little more mature and grown up than you are. |
Look whos talking! Why can't you just drop the subject! Also, since when did this topic envolve you!
I'm getting sick and tired of this along as everyone else, I may as well just stick to MSN if people can't atleast act like they want to help each other with out making stupid, ignorant comments! |
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Thu Jul 06, 2006 11:49 am Post subject: |
|
|
MrWiseOne wrote: | Look whos talking! Why can't you just drop the subject! Also, since when did this topic envolve you!
I'm getting sick and tired of this along as everyone else, I may as well just stick to MSN if people can't atleast act like they want to help each other with out making stupid, ignorant comments! |
To be honest I think you're just over-sensitive.
Nobody thus far as meant any offense to you, yet you act like they've stabbed you in the heart. Cool down a little.
Tim1681 has already made the effort to try and help you. Why don't you try that and read this.
I also assume this is going to be interpreted as another stab in the heart, so carry on. _________________
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Thu Jul 06, 2006 12:53 pm Post subject: |
|
|
Well actually your quite right but I assure you that that was not a stab in the heart.
I do take things to heart and I always have but sometimes you forget to look at the situation from another perspective..
And I don't quite understand what exactly is wrong with Tim's code..? |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Jul 10, 2006 4:57 am Post subject: |
|
|
Hi um could someone please give me a hand with fixing Tim's code? |
|
Back to top |
|
|
loloyd -
Joined: 03 Mar 2006 Posts: 435 Location: Philippines
|
Posted: Mon Jul 10, 2006 6:19 am Post subject: |
|
|
Tim1681, if you're going to post pictures like that in here, I suppose you could consider posting those pickets with nudi--- er... I almost forgot. _________________
http://home.loloyd.com/ is online if the logo graphic at left is showing. |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Jul 10, 2006 6:24 am Post subject: |
|
|
Your post is irrelevant to my question. |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Mon Jul 10, 2006 12:48 pm Post subject: |
|
|
i'll see what i can do loloyd ..
modified code; worked for me so I dont see why it wont for you. I forgot to tell you about the Database Table that you also have to change. My script came from an old one i wrote and the table name was 'login' so that's why it says "..INSERT INTO login (ema...".
Code: | <?php
$email = $_POST['email'];
$name = $_POST['name'];
$HAHA = $_POST['HAHA'];
$connection = mysql_connect("localhost","USER","PASSWORD")
or die("Could not connect to the MySQL Database");
$db = mysql_select_db('YOUR_DATABASE', $connection)
or die("Could not select the MySQL Database");
$query = "INSERT INTO YOUR_TABLE (email, name, HAHA) VALUES ('$email', '$name', '$HAHA')";
$result = mysql_query($query)
or die("Query Failed: " . mysql_error());
mysql_close($connection);
?> |
The only things you should have to change are the fields USER, PASSWORD, YOUR_DATABASE, and YOUR_TABLE. Do you have any MySQL experience? _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Jul 10, 2006 12:58 pm Post subject: |
|
|
Not alot of experiance, no.
This is now my code:
Code: | <?php
$email = $_POST['email'];
$name = $_POST['name'];
$topic = $_POST['topic'];
$message = $_POST['message'];
$connection = mysql_connect("192.168.1.102","-blanked-","-blanked-")
or die("Could not connect to the MySQL Database");
$db = mysql_select_db('contact', $connection)
or die("Could not select the MySQL Database");
$query = "INSERT INTO messages (email, name, topic, message) VALUES ('$email', '$name', '$topic', '$message')";
$result = mysql_query($query)
or die("Query Failed: " . mysql_error());
mysql_close($connection);
?> |
lol, test my table http://www.mrwiseone.com/contact.php |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Mon Jul 10, 2006 1:29 pm Post subject: |
|
|
Code: | Query Failed: Table 'contact.messages' doesn't exist |
You don't have a table called "messages" in your "contact" database. So you might wanna add that =] _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Mon Jul 10, 2006 1:37 pm Post subject: |
|
|
Yes well that's the thing I did say I had barely any SQL knowledge. I can run querys, set them up but thats about it... |
|
Back to top |
|
|
richardyork -
Joined: 22 Jun 2004 Posts: 410 Location: United Kingdom
|
Posted: Mon Jul 10, 2006 4:24 pm Post subject: |
|
|
Just a quickie.....
Here's what I've been using for a few years:
Code: | <?php
/* Edit this section */
$to = "user@domain.com"; // E-mail address the feedback is to be sent to
$subject = "Domain.ext Feedback"; // Subject of the e-mail that the feedback will be in
$afterpg = "page.htm"; // Page to be linked to after feedback is submitted (e.g. index.htm)
/* DO NOT EDIT BELOW THIS LINE (Unless you know what you are doing) */
error_reporting(1);
# Compliance check
if($to == "user@domain.com") {
print "Please ensure that you have editted this file, as it told you to!";
exit;
}
# Mail the result
if(isset($submit) && ($email) && ($message)) {
if (eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
print "<br><center><font face='Verdana' size='3'><b>Success! Your feedback was sent successfully - Thank-you.</b><br>Click <a href='".$afterpg."'>here</a> to continue...</font><br><br></center>";
mail($to, $subject, "$message
IP: $REMOTE_ADDR", "From: $email") or print "ERROR: Mail was not sent";
}
}
?>
<p align="center"><font size="4" face="Verdana"><strong>Feedback</strong></font></p>
<form method="post" action="<?=$PHP_SELF;?>">
<font face="Verdana" size="1">Your e-mail address:</font><br>
<input type="text" size="20" maxlength="72" name="email" value="<?=$email;?>"><?if(isset($submit) && (!$email)) {echo " <font face='Verdana' size='1' color='#FF0000'><b>Enter your e-mail address</b></font>";} elseif (isset($submit) && !eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {echo " <font face='Verdana' size='1' color='#FF0000'><b>Enter a valid e-mail address</b></font>";}?><br><br>
<font face="Verdana" size="1">Your message:</font><br>
<textarea name="message" rows="6" cols="40"><?=$message;?></textarea><?if(isset($submit) && (!$message)) {echo " <font face='Verdana' size='1' color='#FF0000'><b>Enter your message</b></font>";}?><br>
<p><input type="submit" name="submit" value="Send"></p>
</form>
|
Just save it as Contact.php or something.
All you need is PHP and an email server, I use ArGoSoft Free. It's easy to install/configure and use :-) _________________ Please SEARCH the forums BEFORE asking questions! |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Jul 11, 2006 2:22 am Post subject: |
|
|
Where?: My sites contact page...
My php Configuration file extract for SMTP:
Code: | [mail function]
; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 25
; For Win32 only.
;sendmail_from = mrwiseone@[NOSPAMINGFROMTHEFORUMSI'MNOTREALLYINTHECONFIGFILE...]gmail.com
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =
; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =
|
|
|
Back to top |
|
|
loloyd -
Joined: 03 Mar 2006 Posts: 435 Location: Philippines
|
Posted: Tue Jul 11, 2006 5:11 am Post subject: |
|
|
could somebody please verify if we can use gmail's smtp non-authoritatively? i tried telnetting it at port 25 and emulating some smtp commands but it wouldn't commit.
mrwiseone, i think you should uncomment your "sendmail_from" specification from your php.ini and put a qualified email address on it. _________________
http://home.loloyd.com/ is online if the logo graphic at left is showing. |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Jul 11, 2006 5:31 am Post subject: |
|
|
Correct if I am wrong but not only do I no longer like you but you treat me like I have little experiance if any at all.. I've have always used GMAIL for my forms and it HAS worked previously even without secure ports.
The following is a PM on this forum:
EDIT: Fantasic great work on getting my other Topic locked and now possibly this one. AGE AGE AGE Is that your only damn defense! I defend Andy and others because they have reason and sometimes worthy threats like Ddosing me :o
Phirez, how could you not see that Andy's site is copyrighted!? He advertises it almost everywhere not to mention it can and always has been possible to spot it somewhere on every page!
Yes, yes I'm quite Angry. Not directly at anyone either (No Sarcasim).
I don't know where to begin... Onestly now I'm at a Mental state with this forum, in future I will take part in this forum and someone had better document this! I will never ever post any topic related directly to me ever ever again!
Ahhahhahh!!! So angry... Losing controll! turning green! Scratch last line..
EDIT 2:
Andy, I hope to see you on MSN soon so we can discuss our problems and resolve with out being rudely interupted.. (I won't mention names...)
Aprelium please also lock this topic at will.. |
|
Back to top |
|
|
loloyd -
Joined: 03 Mar 2006 Posts: 435 Location: Philippines
|
Posted: Tue Jul 11, 2006 8:33 am Post subject: Hey, calm down and cool off |
|
|
I never treated you like you didn't know anything, as I was merely offering my thoughts on what you said at the beginning of the topic: MrWiseOne wrote: | Any help or suggestions would be greatly appreciated for both the site and the script, | . It was never my intention to treat you like you have little experience. In fact, I have never been condescending to anyone in this forum regardless of their circumstances. It is only the truth when I said that I *am really unable* to use the smtp server smtp.gmail.com for sending email. Congrats to you as you made it work for you!
I cannot promise that I wouldn't be responding to your next threads as this is a public forum and I am simply exercising my privileges in doing so. And I learn a lot from everybody, from newbies to experts, so I read threads whenever I can. Even Aprelium has attested once that it gets some nice ideas from newbies. I believe that fact because it is also true that the most thoughtful questions about life in general come from little kids. I have even personally observed instances where knowledge and maturity has clouded creativity, vision and wisdom. Have you ever heard about where Einstein's fantastic ideas come from?
Calm down and cool off, man. Webserving should be fun, educational and entertaining. Let's make it stress-free as much as possible, alright? Lighten up. _________________
http://home.loloyd.com/ is online if the logo graphic at left is showing. |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Jul 11, 2006 12:43 pm Post subject: |
|
|
What ever you say Grampa. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Tue Jul 11, 2006 1:41 pm Post subject: |
|
|
Flaming each other will harm the forum's friendly atmosphere. So please refrain from using insults and offending expressions in your messages.
Thanks for your understanding. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Moxxnixx -
Joined: 21 Jun 2003 Posts: 1226 Location: Florida
|
Posted: Tue Jul 11, 2006 2:05 pm Post subject: |
|
|
loloyd wrote: | could somebody please verify if we can use gmail's smtp non-authoritatively? i tried telnetting it at port 25 and emulating some smtp commands but it wouldn't commit. |
Unfortunately, Gmail requires SMTP authentication. The only way around it is to use a script that bypasses
PHP's native mail() function. Have a look at Swift Mailer. It has TLS support for Gmail servers. An example
script for using it with Gmail can be found here... http://www.swiftmailer.org/documentation/52#view
Hope that helps. ;) |
|
Back to top |
|
|
Tim1681 -
Joined: 17 Jan 2005 Posts: 160 Location: Bristol, CT, USA
|
Posted: Tue Jul 11, 2006 2:19 pm Post subject: |
|
|
Personally I would've asked the same question as loloyd since I needed to use Auth and port 995 SSL in order to send mail through Gmail with Mozilla Thunderbird .. so it wasnt exactly a post questioning your 'little experience' _________________ mysql> SELECT * FROM users WHERE clue > 0;
0 rows returned.
|
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Jul 11, 2006 11:26 pm Post subject: |
|
|
I assure you, I've bludged Gmail's security before. |
|
Back to top |
|
|
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Tue Jul 11, 2006 11:49 pm Post subject: |
|
|
Then why aren't you doing it now, if you claim it already works for your forms? _________________
"Invent an idiot proof webserver and they'll invent a better idiot..." |
|
Back to top |
|
|
Tom Chapman -
Joined: 09 Jul 2005 Posts: 933 Location: Australia
|
Posted: Tue Jul 11, 2006 11:57 pm Post subject: |
|
|
You leave me in the most awkward of positions. :) |
|
Back to top |
|
|
loloyd -
Joined: 03 Mar 2006 Posts: 435 Location: Philippines
|
Posted: Wed Jul 12, 2006 7:02 am Post subject: |
|
|
Moxxnixx wrote: | Unfortunately, Gmail requires SMTP authentication. The only way around it is to use a script that bypasses
PHP's native mail() function. Have a look at Swift Mailer. It has TLS support for Gmail servers. An example
script for using it with Gmail can be found here... http://www.swiftmailer.org/documentation/52#view
Hope that helps. ;) | Thanks for the info, Moxxnixx. That does help. Although this introduces a need for the Swift package, it indeed enables us to use Gmail as an SMTP server. This empowers me to choose between a locally hosted but easily blocked SMTP server (Blat or Argosoft) - or - one that is almost always on, does the job effortlessly and provides "almost" no webserver burden on the actual sending of emails (Gmail). _________________
http://home.loloyd.com/ is online if the logo graphic at left is showing. |
|
Back to top |
|
|
|