|
|
#1 |
|
Bronze Member
![]() Join Date: Jan 2010
Location: New York
Posts: 93
|
I'm new to PHP and I'm trying to create a very simple php email form. How do I get it so that the page does not reload to a blank white page with just a text thank you message?
Link: http://www.katieful.com/contact2.html HTML Form: HTML Code:
<form method="POST" name="form" onsubmit="return validate(this)" action="mail.php" accept-charset="utf-8"> <div> <label for="name">Name</label> <input type="text" name="name" id="name" value="" maxlength="25" /> </div> <div> <label for="org">Organization</label> <input type="text" name="org" id="org" value="" /> </div> <div> <label for="email">Email</label> <input type="text" name="email" id="email" value="" /> </div> <div style="height: 154px;"> <label for="message">Is there anything else you want to say?</label> <textarea id="message" name="message" cols="5" rows="2"></textarea> </div> <input type="submit" class="submit" value="Submit!" style="width: 96px; float:left; margin-top: 8px;" onmouseover="this.className='submithover'" onmouseout="this.className='submit'" /> </form> Code:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$org = $_POST['org'];
$message = $_POST['message'];
$formcontent="Hello Katie! You just got an email from Katieful! Happy new client dance! \n\nFrom:$name \nEmail: $email \nOrganization: $org \nMessage: $message";
$recipient = "katie@katieful.com";
$subject = "Katieful Message from $email";
$mailheader = "From: $email rn";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "";
?>
__________________
http://www.katieful.com - Web Design Portfolio of Katie Chin. http://www.twitter.com/katiechin - Twitter |
|
|
|
|
|
#2 |
|
Bronze Member
![]() Join Date: Jan 2010
Location: New York
Posts: 93
|
Nevermind, I figured it out!
__________________
http://www.katieful.com - Web Design Portfolio of Katie Chin. http://www.twitter.com/katiechin - Twitter |
|
|
|
|
|
#3 |
|
Silver Member
![]() Join Date: Jul 2010
Location: Queensland, Australia
Posts: 119
|
I wouldn't use that script if I were you. Spambots will have a feast as it's easily exploited to send spam.
__________________
I do Web Design, Brisbane - Gold Coast based. Spend a lot of time in PHP/MySQL Web Development. And Search Engine Optimisation chews up the rest. |
|
|
|
|
|
#4 |
|
New Member
![]() Join Date: Sep 2010
Posts: 7
|
you can redirect in any page using php function header:
header('Location: mypage.html'); better if you test the result of mail function, something like this: if (mail($recipient, $subject, $formcontent, $mailheader)) { header('Location: my_success_page.html'); } else { header('Location: my_fault_page.html'); } |
|
|
|
|
|
#5 |
|
New Member
![]() Join Date: Oct 2010
Posts: 4
|
you can link it back to the contact form but since you guess it already it might be useful for other to know how'd you do it.
__________________
See my DrePro's Web Articles for other web topics. |
|
|
|
![]() |
| Tags |
| echo, form, php |
| Thread Tools | |
| Display Modes | |
|
|