|
Page 1 of 1 |
|
Posted: Tue, 13th Jul 2010 15:07 Post subject: Html form email |
|
 |
So I'm doodling with my site again (I'm bored and I need to wait for my parents to come back from vacation for new comp -.-) and I made an email form so that ppl who come to my site can write how awesome I am
Anywho... I made the form and it works, but when I tested the email submission (I clicked send button) the site opened outlook for that and I would like that it would just send mail without the need of outlook.
I have jquery involved and I read that you can do that in php (sending without outlook), but my site is just plain html+css+jquery.
code is:
Code: | <form action="imnotgivingyou@my.mail.adress" method="post">
<label>Your Name <span>(Required)</span></label>
<span class="field"><input type="text" name="" value="" /></span>
<label>Your E-Mail <span>(Required)</span></label>
<span class="field"><input type="text" name="" value="" /></span>
<label>Message <span>(Required)</span></label>
<span class="textarea-field"><textarea name="" rows="6" cols="10"></textarea></span>
<input type="submit" class="submit" value="Submit">
</form> |
Can that be done via jquery?
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 15:15 Post subject: |
|
 |
Hmm, I'm quite sure you need a server-side language for that (php for example). And a POP server of course.
It opens outlook because the 'action' is an email address, and when you click send whatever default mail programme you have tries to open it.
|
|
Back to top |
|
 |
Werelds
Special Little Man
Posts: 15098
Location: 0100111001001100
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 16:10 Post subject: |
|
 |
So I just put php code in my index.html instead of this and I should be alright?
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
|
|
Back to top |
|
 |
garus
VIP Member
Posts: 34200
|
Posted: Tue, 13th Jul 2010 16:11 Post subject: |
|
 |
snip
Last edited by garus on Tue, 27th Aug 2024 21:27; edited 1 time in total
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 16:32 Post subject: |
|
 |
So I make just those two (form.html and send.php) and include them somehow? I'm a bad coder 
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
|
|
Back to top |
|
 |
Werelds
Special Little Man
Posts: 15098
Location: 0100111001001100
|
|
Back to top |
|
 |
garus
VIP Member
Posts: 34200
|
Posted: Tue, 13th Jul 2010 16:42 Post subject: |
|
 |
snip
Last edited by garus on Tue, 27th Aug 2024 21:27; edited 1 time in total
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 16:49 Post subject: |
|
 |
garus wrote: | Yeah, well. It needs adjustments but that's up to you, depending on how popular your site is  |
Well ppl go there to get various ebooks so I wouldn't want unnecessary mail :\
I'll see it out Thanks guys ^^
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 17:04 Post subject: |
|
 |
Well then better adjust the script to make it more secure 
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 19:21 Post subject: |
|
 |
EDIT: I found this:
Code: | <?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Invalid input";
}
else
{//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", "Subject: $subject",
$message, "From: $email" );
echo "Thank you for using our mail form";
}
}
else
{//if "email" is not filled out, display the form
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?> |
So I save that as send.php put it into my public.html and how to incorporate that into that form I gave? As garus said?
EDIT2: Ok so it works, but I deleted that last part (don't know what that mailform.php does or where to get it ).
EDIT3:
So my final code is this:
Code: | <?php
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
return TRUE;
}
else
{
return FALSE;
}
}
if (isset($_REQUEST['email']))
{//if "email" is filled out, proceed
//check if the email address is invalid
$mailcheck = spamcheck($_REQUEST['email']);
if ($mailcheck==FALSE)
{
echo "Krivi unos!";
}
else
{//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("xxx@x.x.x", "Subject: $subject",
$message, "From: $email" );
echo "Hvala sto koristite moj e-mail formular ^^";
echo "<meta http-equiv='refresh' content='=5; index.html' />";
}
}
?> |
The last echo will get me back from the Thank you note in Cro But I would like that the page would be visible for at least 5 sec, this just blinks... Do I increase content number or?
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
Last edited by dingo_d on Tue, 13th Jul 2010 19:48; edited 1 time in total
|
|
Back to top |
|
 |
Werelds
Special Little Man
Posts: 15098
Location: 0100111001001100
|
Posted: Tue, 13th Jul 2010 19:47 Post subject: |
|
 |
Erm that code above is mailform.php 
|
|
Back to top |
|
 |
|
Posted: Tue, 13th Jul 2010 19:50 Post subject: |
|
 |
oh... lol what does it do? I mean that last part? I named it send.php, so I would just need to put instead mailform.php send.php, right?
But what does that do? It will shout sth (I guess with echo...)
"Quantum mechanics is actually, contrary to it's reputation, unbeliveably simple, once you take the physics out."
Scott Aaronson chiv wrote: | thats true you know. newton didnt discover gravity. the apple told him about it, and then he killed it. the core was never found. |
|
|
Back to top |
|
 |
Werelds
Special Little Man
Posts: 15098
Location: 0100111001001100
|
Posted: Tue, 13th Jul 2010 20:03 Post subject: |
|
 |
Basically it checks if there's an email in the POST values, verifies that and sends an email, and if there's no email in the POST values it displays the form.
You should take a crash course in PHP, tons of tutorials out there, and it's easy to pick up 
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group
|
|
 |
|