php form displaying blank page?

lolkaykay

New Member
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:
<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>

And here's my mail.php:
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 = "[email protected]";
$subject = "Katieful Message from $email";
$mailheader = "From: $email rn";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "";
?>

Thanks!
 

v2Media

Member
I wouldn't use that script if I were you. Spambots will have a feast as it's easily exploited to send spam.
 

logoarena

New Member
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');
}
 

z0alexander

New Member
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.
 
Top