Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-06-2005, 10:08 AM   PM User | #1
pml
New Coder

 
Join Date: Mar 2005
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
pml is an unknown quantity at this point
How can I use webmail on when I use my computer as a webserver?

I am running Win XP Professional and have been told that I should be able to use my computer as a webserver (which I know how to do) and also use Webmail (but I don’t know how to do that). Therefore I wonder if anyone knows how to set up webmail (or can provide a useful link about the topic) so I can use a form on my webpage to send e-mails to my e-mail account with the ISP.
pml is offline   Reply With Quote
Old 03-06-2005, 11:19 AM   PM User | #2
miggsy007
New Coder

 
Join Date: Oct 2004
Posts: 77
Thanks: 0
Thanked 0 Times in 0 Posts
miggsy007 is an unknown quantity at this point
If all you're doing is taking values from an email form and then emailing them to a certain email address, then it's easy. I managed it no problem and I'd never even heard of PHP 60 posts ago. Here's a simple example. Put the two files in the same directory, or alter the path in your form.

XHTML:

Code:
// Sets up the form to process the results using 'sendmail.php. Alter the path
// if 'sendmail.php' is in a different directory.

<form method="post" action="sendmail.php">

// Supplies a hidden value that will tell you what page the user came from.
// Not essential, only useful if you have more than one form like this.

<input type="hidden" name="page" value="Name of the page the form is on." class="textform"/>

// The actual form. Add extra inputs if you want more fields.

<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" size="40" class="textform"/></td>
</tr>
<tr>
<td>Email Address</td>
<td><input type="text" name="email" size="40" class="textform"/></td>
</tr>
<tr>
<td>Notes</td>
<td><textarea name="notes" rows="10" cols="40" class="textform"></textarea></td>
</tr>
<tr>
<td align="right"><input type="reset" value="Clear"/></td>
<td><input type="submit" value="Send Info"/></td>
</tr>
</table>

</form>

OK, so put that in your XHTML page, editing the style to match your page. It will send the values 'page' (which might not be necessary), 'name', 'email' and 'notes' to 'sendmail.php'. Adding more fields is easy enough, just put more inputs in with the relevant details.

Now the code for sendmail.php.

PHP Code:
<?php

// Puts the user's email address in the variable $email.

  
$email $_REQUEST['email'] ;
  
// Puts the message together. The bits in the "" are actual text, the other bits
// will insert the details from the form. \n is a line break.

  
$message "Page:";
  
$message .= $_REQUEST['page'];
  
$message .= "\nName:";
  
$message .= $_REQUEST['name'];
  
$message .= "\nNotes:";
  
$message .= $_REQUEST['notes'];

// Sends the email to 'target@address.com' with a subject of 'Subject Of
// Email'. Inserts the message in the email. Says it's from the user's email
// address.

  
mail"target@address.com""Subject Of Email",
    
$message"From: $email" );

// Redirects the user to [url]www.yoursite/thanks.html[/url].


  
header"Location: http://www.yoursite/thanks.html" );
?>

OK, so obviously you have to change a few things there to reflect your site and your email address.

The

PHP Code:
.= 
function in PHP means 'add this to what's already there' so

PHP Code:
$message .= $_REQUEST['notes']; 
means 'add 'notes' to the end of $message'. So if you've added new fields to your form in the XHTML you need to add them here too. For example, if there was an input in your form named 'location', you'd need to alter the bit that generates the message in the PHP to this:

PHP Code:
$message "Page:";
  
$message .= $_REQUEST['page'];
  
$message .= "\nName:";
  
$message .= $_REQUEST['name'];
  
$message .= "\nNotes:";
  
$message .= $_REQUEST['notes'];
  
$message .="\nLocation:";
  
$message .= $_REQUEST['location']; 

So say some one fills in the form like this:

Name Me
Email me@me.com
Notes Hello world!
Location Somewhere

this would send an email to the address you specify that looks like his:

Name : Me
Email : me@me.com
Notes : Hello world!
Location : Somewhere

Hope this helps. It's the second bit of PHP advice I've given out. Let me know if it works!

Miggsy007
__________________
Please visit My Site - Especially if you play CS or DoW.

'Don't worry men, they couldn't hit a bull at this distance.' - Last words of General Patton
miggsy007 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:22 AM.


Advertisement
Log in to turn off these ads.