我有Joomla 1.7工作。我想在其中一个页面中包含订单。我有这部分代码,但问题是它没有将数据提交到电子邮件。如何更改数据要提交?这是代码的一部分。
<div class="orderform"><form id="order_form" method="post" name="order_form">>
<table>
<tbody id="personal_info">
<tr class="label"><th colspan="2">Personal Information</th></tr>
<tr id="row_firstname">
<td class="label">
<div><label for="firstname">First name:<span class="required_star">*</span></label>
</div>
</td>
<td>
<div><input id="firstname" type="text" name="firstname" value="" />
<div id="error_firstname" class="validation_error">Enter your first name</div>
</div>
</td>
</tr>
<tr id="row_lastname">
<td class="label">
<div><label for="lastname">Last name:<span class="required_star">*</span></label></div>
</td>
<td>
<div><input id="lastname" type="text" name="lastname" value="" />
<div id="error_lastname" class="validation_error">Enter your last name</div>
</div>
</td>
</tr>
<tr id="row_email">
<td class="label">
<div><label for="email">Email:<span class="required_star">*</span></label></div>
</td>
<td>
<div><input id="email" type="text" name="email" value="" />
<div id="error_email" class="validation_error">Enter valid email address</div>
</div>
</td>
</tr>
<tr id="row_retype_email">
<td class="label">
<div><label for="retype_email">Re-type email:<span class="required_star">*</span></ label></div>
</td>
<td>
<div><input id="retype_email" type="text" name="retype_email" value="" />
<div id="error_retype_email" class="validation_error">Emails do not coincide</div>
</div>
</td>
</tr>
答案 0 :(得分:0)
你需要php,例如:
<?php
if (isset($_POST['Submit'])) {
if ($_POST['name'] != "") {
$_POST['name'] = filter_var($_POST['name'], FILTER_SANITIZE_STRING);
if ($_POST['name'] == "") {
$errors .= 'Please enter a valid name.<br/><br/>';
}
} else {
$errors .= 'Please enter your name.<br/>';
}
if ($_POST['email'] != "") {
$email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors .= "$email is <strong>NOT</strong> a valid email address.<br/><br/>";
}
} else {
$errors .= 'Please enter your email address.<br/>';
}
if ($_POST['homepage'] != "") {
$homepage = filter_var($_POST['homepage'], FILTER_SANITIZE_URL);
if (!filter_var($homepage, FILTER_VALIDATE_URL)) {
$errors .= "$homepage is <strong>NOT</strong> a valid URL.<br/><br/>";
}
} else {
$errors .= 'Please enter your home page.<br/>';
}
if ($_POST['message'] != "") {
$_POST['message'] = filter_var($_POST['message'], FILTER_SANITIZE_STRING);
if ($_POST['message'] == "") {
$errors .= 'Please enter a message to send.<br/>';
}
} else {
$errors .= 'Please enter a message to send.<br/>';
}
if (!$errors) {
$mail_to = 'me@somewhere.com';
$subject = 'New Mail from Form Submission';
$message = 'From: ' . $_POST['name'] . "\n";
$message .= 'Email: ' . $_POST['email'] . "\n";
$message .= 'Homepage: ' . $_POST['homepage'] . "\n";
$message .= "Message:\n" . $_POST['message'] . "\n\n";
//mail($to, $subject, $message);
echo "Thank you for your email!<br/><br/>";
} else {
echo '<div style="color: red">' . $errors . '<br/></div>';
}
}
?>
<form name="form1" method="post" action="form-email.php">
Name: <br/>
<input type="text" name="name" value="<?php echo $_POST['name']; ?>" size="50" /><br/><br/>
Email Address: <br/>
<input type="text" name="email" value="<?php echo $_POST['email']; ?>" size="50"/> <br/><br/>
Home Page: <br/>
<input type="text" name="homepage" value="<?php echo $_POST['homepage']; ?>" size="50" /> <br/><br/>
Message: <br/>
<textarea name="message" rows="5" cols="50"><?php echo $_POST['message']; ?></textarea>
<br/>
<input type="submit" name="Submit" />
</form>
只需确保您的FORM页面的名称是:form-email.php(在FORM HTML中查找操作并根据需要进行更改)。此脚本已经过测试,只需将其正确插入Joomla页面即可使用。