|  | |
07-25-2008, 04:27 PM
|
#1 (permalink)
|
Ultra Techie Join Date: Jun 2007 Location: Surrey, UK Posts: 849
| 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?
__________________ |
| |
07-25-2008, 04:38 PM
|
#2 (permalink)
|
T.F's Resident Cool Guy... Join Date: Aug 2006 Posts: 1,625
| 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 |
| |
07-25-2008, 04:58 PM
|
#3 (permalink)
|
Ultra Techie Join Date: Jun 2007 Location: Surrey, UK Posts: 849
| 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
__________________ |
| |
07-25-2008, 07:49 PM
|
#4 (permalink)
|
I am of the highest lvl.. Join Date: Oct 2007 Location: Sydney, Australia Posts: 2,458
| 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.
|
| |
07-25-2008, 09:30 PM
|
#5 (permalink)
|
Ultra Techie Join Date: Jun 2007 Location: Surrey, UK Posts: 849
| 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.
__________________ |
| |
07-25-2008, 11:13 PM
|
#6 (permalink)
|
I am of the highest lvl.. Join Date: Oct 2007 Location: Sydney, Australia Posts: 2,458
| 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.
|
| |
07-26-2008, 12:07 AM
|
#7 (permalink)
|
Ultra Techie Join Date: Jun 2007 Location: Surrey, UK Posts: 849
| 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.
__________________ |
| |
07-26-2008, 10:25 PM
|
#8 (permalink)
|
I am of the highest lvl.. Join Date: Oct 2007 Location: Sydney, Australia Posts: 2,458
| 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;
}
$validemail= check_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" |
| |
07-27-2008, 08:11 AM
|
#9 (permalink)
|
Ultra Techie Join Date: Jun 2007 Location: Surrey, UK Posts: 849
| Re: Form emails me on Submission do i put this before or after the code that emails them?
__________________ |
| |
07-28-2008, 07:18 PM
|
#10 (permalink)
|
Wizard Techie Join Date: Feb 2006 Location: Maine Posts: 3,690
| 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! |
| |  | | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | |