Html Posted October 1, 2007 Share Posted October 1, 2007 Hi there, can anyone here write up a simple contact form, and your email is hidden, so you get my drift? Link to comment Share on other sites More sharing options...
Html Posted October 3, 2007 Author Share Posted October 3, 2007 No one? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2007 Share Posted October 3, 2007 I'm sure a lot of people can. Can you? Do you want us to help you do it? What do you have so far? Are the email addresses in a database? Link to comment Share on other sites More sharing options...
Html Posted October 3, 2007 Author Share Posted October 3, 2007 Um, I just want a name box, comment box, on a page. With a simple script which sends the comments to my email? With out showing it ofcourse. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2007 Share Posted October 3, 2007 Sounds good. Do you want someone to write that for you, or are you looking for help writing it yourself? Link to comment Share on other sites More sharing options...
Html Posted October 3, 2007 Author Share Posted October 3, 2007 The php script. I can't really do, as I haven't read and taking the time to learn a little. I can make the comment box and name, um...thats about it. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2007 Share Posted October 3, 2007 If you post the form you want to use we can show you how to use PHP to process the form and send the email. There is also a tutorial on the w3schools site about PHP Forms, and you can check the PHP tips sticky thread in this forum for another description about how to process forms. Sending email is easy, there is a mail function that you can use to do that once you have all the form info. Link to comment Share on other sites More sharing options...
Html Posted October 3, 2007 Author Share Posted October 3, 2007 <form action=".php" method="post"><br>Name:<input type="text" name="name"<br><br>Commens:<br><textarea name="text" rows="8" cols="30"></textarea><br><input type="submit"></form> Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2007 Share Posted October 3, 2007 In the PHP script that processes that, you can access name using $_POST['name'] and the comments field using $_POST['text'], since those are the names that you gave to the elements. You can check if those are empty in the script, and build your email message. Then you can use the mail function to send the mail. Here are two examples from php.net of sending a simple mail, and another one with extra headers. <?php// The message$message = "Line 1\nLine 2\nLine 3";// In case any of our lines are larger than 70 characters, we should use wordwrap()$message = wordwrap($message, 70);// Sendmail('caffinated@example.com', 'My Subject', $message);?> <?php$to = 'nobody@example.com';$subject = 'the subject';$message = 'hello';$headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();mail($to, $subject, $message, $headers);?> http://www.php.net/manual/en/function.mail.phpTry out a couple things and see how it goes, make sure to also check the PHP forms resources I mentioned earlier. Link to comment Share on other sites More sharing options...
Html Posted October 4, 2007 Author Share Posted October 4, 2007 Hmm, I'm not quite concentrated on learn php... Um, I uploaded a page and the script is added to it. http://richard.joolo.com/email/I used the basic code you posted up here, and checked out the php site. Not exactly very intuitive for a first timer. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 4, 2007 Share Posted October 4, 2007 It's probably more intuitive then you think, the mail function is pretty simple to use (thankfully we don't need to worry about the actual mail transfer behind the scenes). All you need to send an email is the subject, the To address, and the message. Optionally you can add the From address and whatever else (the second example does that).The subject and the To address will probably remain the same, so all you need to worry about is building the message. You can get the form values using the $_POST array, and from there you just need to build the message string. You can use the \n character for a newline. $message = "Name: {$_POST['name']}\nComments: {$_POST['text']}"; The first example above also uses the wordwrap function to make sure lines aren't too long, some mail agents have problems with long lines for whatever reason. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.