[英]Php contact form path or?
我正在使用Joomla 3,我創建了一個簡單的php表單,並且在一個簡單的html頁面上工作,但是當我嘗試將其與joomla一起使用時,並沒有做任何事情,我在FTP服務器上使用了它,而不是本地的
我試過<?php include(' component.php'); ?>
<?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>
我有一個不同的文件,稱為component和<?php include('component.php');
該文件進入index.php,其中我的表單完整的路徑是“ htdocs / templates / mytemplate / component.php”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.