PHP联系表单路径或?

时间:2015-05-09 23:49:12

标签: php html forms email joomla

我正在使用Joomla 3和我创建一个简单的PHP表单,它正在一个简单的HTML页面,但当我试图使用它与joomla没有做任何事情 我在FTP服务器上使用它而不是本地两种情况

我试过<?php include(' component.php'); ?>但同样我不知道该做什么我不是用PHP专业,joomla请帮忙

component.php文件         

defined('_JEXEC') or die;

$errors = '';
$myemail = 'hety@gmail.com';//<---- email address .
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['text']))
{
    $errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$password = $_POST['text']; 
if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
    $to = $myemail; 
    $email_subject = "Contact form submission: $name";
    $email_body = "You have received a new message. /n ".
    " Here are the details:\n Name: $name \n Email: $email_address \n Text: $text \n"; 

    $headers = "From: $myemail\n"; 
    $headers .= "Reply-To: $email_address";

    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: index.php');
} 
?>
<!DOCTYPE html> 
<html>
<head>
    <title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>

index.php文件

<form method="POST" name="contactform" action="templates/oniongraphicscomponent.php"> 
<p style="color:#FBFF94"> Character Name </p>
<input class="form-field" type="text" name="name" required/>
<input class="form-field"  type="text" name="text" required />
<div class="form-title"><p style="color:#FBFF94"> Email </p></div>
<input class="form-field" type="text" name="email"required /><br><br>
<div class="submit">
<input class="submit" type="submit" value="Submit" />
</div>
</form>

1 个答案:

答案 0 :(得分:0)

我有一个名为component的不同文件和<?php include('component.php');文件到我的表单所在的index.php文件中 完整路径是'htdocs / templates / mytemplate / component.php'