Hi. I am new to PHP though i have a small background in C++ (took a intro course in college). I am wondering if this is legal to do:
-
<form action="<?
-
$name = $HTTP_POST_VARS['name'];
-
$fromemail = $HTTP_POST_VARS['fromemail'];
-
$subject = $HTTP_POST_VARS['subject'];
-
$message = $HTTP_POST_VARS['message'];
-
$date = date('M.j.y');
-
$header = "From: $name <$fromemail>" . "Date: $date";
-
-
-
if ($name == "")
-
{
-
echo "<p>Please provide your name</p>";
-
}
-
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $fromemail))
-
{
-
$fromemail = "not provided";
-
}
-
if ($subject == "")
-
{
-
$subject = "message from user";
-
}
-
if (mail("admin@blabla.com",$subject,$message,$header))
-
{
-
echo "<p>Thank you for sending the email.</p>";
-
} else {
-
echo "<p>Can not send the email. Please try again later.</p>";
-
}
-
?>" method="post">
-
<p>Name:<input name="name" type="text" size="20" /></p>
-
<p>Subject: <input name="subject" type="text" size="30" /></p>
-
<p>Message: <textarea name="message" cols="35" rows="5" /></textarea></p>
-
<p align="left"><input type="submit" value="send" /></p>
-
</form>
-
Also, for the
-
if (mail("admin@blabla.com",$subject,$message,$header))
-
{
-
echo "<p>Thank you for sending the email.</p>";
-
} else {
-
echo "<p>Can not send the email. Please try again later.</p>";
-
}
Is there a way I can put this message in place of the forms instead of going to another page? Or would i have to use the main template and make it so the code is on a whole seperate page?
Thank you