Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » Form emails me on Submission
Closed Thread
Old 07-25-2008, 04:27 PM   #1 (permalink)
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Form emails me on Submission

Hi, i need to find a way of getting to email me the details when the form has been filled in. I tried the action="MAILTO:blah@blah.com" but it just opened up my email client. I dont want it to do this. I know HTML and CSS, and some PHP, but otherwise i have no idea how to do this. can anyone help meee?
__________________

murdocsvan is offline  
Old 07-25-2008, 04:38 PM   #2 (permalink)
Yek
 
T.F's Resident Cool Guy...

Join Date: Aug 2006

Posts: 1,625

Yek is on a distinguished road

Send a message via AIM to Yek Send a message via MSN to Yek Send a message via Yahoo to Yek Send a message via Skype™ to Yek
Default Re: Form emails me on Submission

You can either do this with HTML or PHP.
Which is your prefered method?

(Note that PHP is less "spam friendly" if you like )

Cheers,

~ Tkey
Yek is offline  
Old 07-25-2008, 04:58 PM   #3 (permalink)
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Re: Form emails me on Submission

HTML. but if its the <form action="MAILTO: " then i dont want that, because that wont work. im making a website for the in-game browser in EVE online, which has very limited coding capabilities. it supports HTML 3.2, and CSS, and a few others.

thanks
__________________

murdocsvan is offline  
Old 07-25-2008, 07:49 PM   #4 (permalink)
zedman3d's Avatar
 
I am of the highest lvl..

Join Date: Oct 2007

Location: Sydney, Australia

Posts: 2,458

zedman3d will become famous soon enoughzedman3d will become famous soon enough

Default Re: Form emails me on Submission

PHP Code:
<?php
$message 
$_POST['message'];
mail('youremail@gmail.com''Subject'$message);
?>
Thats it in PHP, needs abit of tweeking depending on how and where it is used. If you need any help with using it just post your code.
__________________



My pick up line is: I know Vernong.

Trotter: "Ask all the questions you want... whatever we don't know, we'll make
up something that sounds pretty good."

Antec-User: "I have a display now, but the darn system is crash-bandicoot on stock"

Last edited by zedman3d; 07-25-2008 at 07:52 PM.
zedman3d is offline  
Old 07-25-2008, 09:30 PM   #5 (permalink)
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Re: Form emails me on Submission

Code:
<form action="MAILTO:planetaliens98@hotmail.com" method="post" enctype="text/plain"> 
				<p>
					Character Name
						<input type="text" name="firstname">
				</p>
				<p>
					First Name IRL 
						<input type="text" name="lastname">
				</p>
				<p>
					Character Race
						<select name="race">
							<option value="gallente">Gallente</option>
							<option value="caldari">Caldari</option>
							<option value="minmitar">Minmitar</option>
							<option value="amarr">Amarr</option>
						</select>
				<p>
					Email
						<input type="text" name="email">
				</p>
				<p>
					<input type="submit" value="Submit">
					<input type="reset" value="Reset">
			</form>
Thats the form im going to use for submission.
__________________

murdocsvan is offline  
Old 07-25-2008, 11:13 PM   #6 (permalink)
zedman3d's Avatar
 
I am of the highest lvl..

Join Date: Oct 2007

Location: Sydney, Australia

Posts: 2,458

zedman3d will become famous soon enoughzedman3d will become famous soon enough

Default Re: Form emails me on Submission

Change the first line with:

PHP Code:
<form name="input" action="submit_contact.php" method="post"
With submit_contact.php being :

PHP Code:
<?php

// Assigning the posted values to variables.
$charactername $_POST['firstname'];
$nameIRL $_POST['lastname'];
$race =  $_POST['race'];
$email $_POST['email'];

// Sending the email with all the info.
mail('planetaliens98@hotmail.com''Subject'"First Name: ".$charactername."   Fire Name IRL: ".$nameIRL."   Race: ".$race."   Submitted by: ".$email." ");
?>
Hope i helped.
PS: Thats the basic way, ask me for more help if you need any. If you get that working, ill give you a good code for checking if the email is correct and exists.
__________________



My pick up line is: I know Vernong.

Trotter: "Ask all the questions you want... whatever we don't know, we'll make
up something that sounds pretty good."

Antec-User: "I have a display now, but the darn system is crash-bandicoot on stock"

Last edited by zedman3d; 07-25-2008 at 11:21 PM.
zedman3d is offline  
Old 07-26-2008, 12:07 AM   #7 (permalink)
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Re: Form emails me on Submission

thanks a lot zedman. i copied the code, but edited it a bit. i was sort of following what you said and what another website said at the same time:

PHP Code:
<?php
$to 
"planetaliens98@hotmail.com";
$subject "Mail List Application";
$first $_POST["first_name"];
$character $_POST["character_name"];
$race $_POST["race"];
$email $_POST["email"];
$message "$first, $character, $race, $email";
$from "NOREPLY@tom.djfhosting.co.uk";
$headers "From: $from";
mail($to,$subject,$message,$headers);
?>
that was the code for the PHP page.

and yes i Would like that code for checking the email is correct lol. currently theres no form of validation, and nothing to stop someone from just flooding my inbox.
__________________

murdocsvan is offline  
Old 07-26-2008, 10:25 PM   #8 (permalink)
zedman3d's Avatar
 
I am of the highest lvl..

Join Date: Oct 2007

Location: Sydney, Australia

Posts: 2,458

zedman3d will become famous soon enoughzedman3d will become famous soon enough

Default Re: Form emails me on Submission

PHP Code:
function check_email_address($email) {
  
// First, we check that there's one @ symbol, 
  // and that the lengths are right.
  
if (!ereg("^[^@]{1,64}@[^@]{1,255}$"$email)) {
    
// Email invalid because wrong number of characters 
    // in one section or wrong number of @ symbols.
    
return false;
  }
  
// Split it into sections to make life easier
  
$email_array explode("@"$email);
  
$local_array explode("."$email_array[0]);
  for (
$i 0$i sizeof($local_array); $i++) {
    if
(!
ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$"
,
$local_array[$i])) {
      return 
false;
    }
  }
  
// Check if domain is IP. If not, 
  // it should be valid domain name
  
if (!ereg("^\[?[0-9\.]+\]?$"$email_array[1])) {
    
$domain_array explode("."$email_array[1]);
    if (
sizeof($domain_array) < 2) {
        return 
false// Not enough parts to domain
    
}
    for (
$i 0$i sizeof($domain_array); $i++) {
      if
(!
ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
?([A-Za-z0-9]+))$"
,
$domain_array[$i])) {
        return 
false;
      }
    }
  }
  return 
true;
}

$validemailcheck_email_address($_POST['email']);

if (
$validemail == false) {
die(
'Sorry, the email '.$_POST['email'].' is invalid. <a href=previous.php>Click Here to go Back.</a>');


__________________



My pick up line is: I know Vernong.

Trotter: "Ask all the questions you want... whatever we don't know, we'll make
up something that sounds pretty good."

Antec-User: "I have a display now, but the darn system is crash-bandicoot on stock"
zedman3d is offline  
Old 07-27-2008, 08:11 AM   #9 (permalink)
murdocsvan's Avatar
 
Ultra Techie

Join Date: Jun 2007

Location: Surrey, UK

Posts: 849

murdocsvan is on a distinguished road

Default Re: Form emails me on Submission

do i put this before or after the code that emails them?
__________________

murdocsvan is offline  
Old 07-28-2008, 07:18 PM   #10 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,690

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: Form emails me on Submission

You can either put it in a functions file (if you use many functions) or you can just leave it in the same page.

That code checks the email, with an if statement at the bottom:

PHP Code:
if ($validemail == false) {
die(
'Sorry, the email '.$_POST['email'].' is invalid. <a href=previous.php>Click Here to go Back.</a>');

So you can just modify that a little to send the email if it returns true:

PHP Code:
if ($validemail == false) {
die(
'Sorry, the email '.$_POST['email'].' is invalid. <a href=previous.php>Click Here to go Back.</a>');
} else {
mail('planetaliens98@hotmail.com''Subject'"First Name: ".$charactername."   Fire Name IRL: ".$nameIRL."   Race: ".$race."   Submitted by: ".$email." ");


__________________

Need website help? PM me!
CrazeD is offline  
 
Closed Thread

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript form cyrax Web Graphics, Design, Digital Images 1 02-03-2008 09:36 PM
Need PHP and JavaScript Form Validation Scripts aetherh4cker Programming Discussions 2 01-06-2008 04:16 PM
HTML E-Mail Form (Outlook issue) Tempest Programming Discussions 2 11-24-2007 02:54 PM
How can I use MS Outlook Contacts track clients emails and clients information? david55 Windows Operating Systems and Software 7 11-12-2007 07:18 AM
Help with downloading emails to outlook 2000 pengyou Browser & General Internet Questions 1 09-04-2007 01:11 PM