-1
このフォームはデータベースにデータを送信していますが、私はクエリがまた2つの他のidsに行く必要があります誰かがsmtpを使用すると述べたが、私はどのように、 。フォームの提出後に電子メールを送信する必要がある場合は、事前jqueryフォームにsmtpを追加する必要があります
<?php
\t \t // Attention! Please read the following.
\t \t // It is important you do not edit pieces of code that aren't tagged as a configurable options identified by the following:
\t \t // Configuration option.
\t \t // Each option that is easily editable has a modified example given.
\t \t $error \t \t \t = '';
\t \t $name \t \t \t = '';
\t \t $email \t \t \t = '';
$organisation \t = '';
\t \t $phone \t \t \t = '';
\t \t $subject \t \t = '';
\t \t $comments \t \t = '';
\t \t //$verify \t \t = '';
\t \t if(isset($_POST['contactus'])) {
\t \t $name \t \t \t \t = $_POST['name'];
\t \t $email \t \t \t \t = $_POST['email'];
$organisation \t \t = $_POST['name'];
\t \t $phone \t \t \t \t = $_POST['phone'];
\t \t $subject \t \t \t = $_POST['subject'];
\t \t $comments \t \t \t = $_POST['comments'];
\t \t //$verify \t \t = $_POST['verify'];
$servername = "localhost";
\t $username = "auweb";
\t $password = "auw3b";
\t $dbname = "auweb";
\t $useragent=$_SERVER['HTTP_USER_AGENT'];
\t $ip=$_SERVER['REMOTE_ADDR'];
\t \t
\t //echo $msg;
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
}
$sql="";
\t if(empty($name)||empty($phone)||empty($email)||empty($subject)||empty($comments)){
\t \t \t $sql = "INSERT INTO `aki_logs` (`ts`, `name`, `email`, `phone`, `state`, `course`, `useragent`, `ip`, `status`)VALUES (now(), '$name', '$email', '$phone', '$comments', '$subject', '$useragent', '$ip', 'Error');";
\t \t
\t \t //echo 'Please enter all the data';
\t
\t \t
\t \t header('location:index.php');
\t \t
\t }
\t else{
\t \t
\t \t \t $sql = "INSERT INTO `aki_logs` (`ts`, `name`, `email`, `phone`, `state`, `course`, `useragent`, `ip`, `status`)VALUES (now(), '$name', '$email', '$phone', '$comments', '$subject', '$useragent', '$ip', 'Success');";
\t \t
\t \t
\t }
\t
\t $conn->query($sql);
\t $conn->close();
\t //$to="[email protected],[email protected]";
\t //$to='[email protected]';
@date_default_timezone_set('Asia/Kolkata');
@session_start();
unset($_POST['formname']); unset($_POST['submit']);
$csv = implode('","', $_POST);
$csv = '"'.date("d-m-Y").'","'. date("H:i:s") .'","' . $csv . '"' . "\r\n";
$file = '../../data/'. basename(__DIR__) .'.csv';
@file_put_contents($file, $csv, FILE_APPEND);
\t \t
\t \t
\t \t // Configuration option.
\t \t // You may change the error messages below.
\t \t // e.g. $error = 'Attention! This is a customised error message!';
\t \t if(trim($name) == '') {
\t \t \t $error = '<div class="error_message">Attention! You must enter your name.</div>';
\t \t } else if(trim($email) == '') {
\t \t \t $error = '<div class="error_message">Attention! Please enter a valid email address.</div>';
\t \t // Configuration option.
\t \t // Remove the // tags below to active phone number.
\t \t } else if(!is_numeric($phone)) {
\t \t // $error = '<div class="error_message">Attention! Phone number can only contain digits.</div>';
\t \t } else if(!isEmail($email)) {
\t \t \t $error = '<div class="error_message">Attention! You have enter an invalid e-mail address, try again.</div>';
\t \t }
\t \t if(trim($organisation) == '') {
\t \t \t $error = '<div class="error_message">Attention! Please enter a subject.</div>';
\t \t } else if(trim($comments) == '') {
\t \t \t $error = '<div class="error_message">Attention! Please enter your message.</div>';
\t \t }// else if(trim($verify) == '') {
\t \t // \t $error = '<div class="error_message">Attention! Please enter the verification number.</div>';
\t \t //} else if(trim($verify) != '4') {
\t \t // \t $error = '<div class="error_message">Attention! The verification number you entered is incorrect.</div>';
\t \t //}
\t \t if($error == '') {
\t \t \t if(get_magic_quotes_gpc()) {
\t \t \t \t $comments = stripslashes($comments);
\t \t \t }
\t \t // Configuration option.
\t \t // Enter the email address that you want to emails to be sent to.
\t \t // Example $address = "";
\t \t $address = "[email protected], [email protected]";
\t \t // Configuration option.
\t \t // i.e. The standard subject will appear as, "You've been contacted by John Doe."
\t \t // Example, $e_subject = '$name . ' has contacted you via Your Website.';
\t \t $e_organisation = 'You\'ve been contacted by ' . $name . '.';
\t \t // Configuration option.
\t \t // You can change this if you feel that you need to.
\t \t // Developers, you may wish to add more fields to the form, in which case you must be sure to add them here.
\t \t $e_body = "You have been contacted by $name with regards to $organisation, their additional message is as follows.\r\n\n";
\t \t $e_content = "\"$comments\"\r\n\n";
\t \t // Configuration option.
\t \t // RIf you active phone number, swap the tags of $e-reply below to include phone number.
\t \t $e_reply = "You can contact $name via email, $email or via phone $phone";
\t \t //$e_reply = "You can contact $name via email, $email";
\t \t $msg = $e_body . $e_content . $e_reply;
\t \t if(mail($address, $e_organisation, $msg, "From: '[email protected]'\r\nReply-To: $email\r\nReturn-Path: $email\r\n"))
\t \t {
\t \t \t // Email has sent successfully, echo a success page.
\t \t \t echo "<div id='succsess_page'>";
\t \t \t echo "<h1>Email Sent Successfully.</h1>";
\t \t \t echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
\t \t \t echo "</div>";
\t \t } else echo "Error. Mail not sent";
\t \t }
\t }
\t \t if(!isset($_POST['contactus']) || $error != '') // Do not edit.
\t \t {
?>
\t \t \t <?php echo $error; ?>
\t \t \t <fieldset>
\t \t \t <legend>Please fill in the following form to contact us</legend>
\t \t \t <form method="post" action="#succsess_page">
<div class="row">
<div class="col-md-6">
\t \t \t <label for=name accesskey=U><span class="required">*</span> Your Name</label>
\t \t \t <input name="name" type="text" id="name" size="30" value="<?php echo $name; ?>" />
\t \t \t <br />
\t \t \t <label for=email accesskey=E><span class="required">*</span> Email</label>
\t \t \t <input name="email" type="text" id="email" size="30" value="<?php echo $email; ?>" />
\t \t \t <br />
\t \t \t
\t \t \t <label for=phone accesskey=P><span class="required">*</span> Phone</label>
\t \t \t <input name="phone" type="text" id="phone" size="30" value="<?php echo $phone; ?>" />
\t \t </div><!--COL-FORM HALF-->
<div class="col-md-6">
\t
\t \t \t <label for=subject accesskey=S><span class="required">*</span> Subject</label>
\t \t \t <select name="subject" id="subject">
\t \t \t \t
\t \t \t \t <option value="B. A. (Hons) - Liberal Arts">B. A. (Hons) - Liberal Arts</option>
\t \t \t \t
\t \t \t </select>
\t \t \t <br />
\t \t \t <label for=comments accesskey=C><span class="required">*</span> Query</label>
\t \t \t <textarea name="comments" cols="30" rows="3" id="comments"><?php echo $comments; ?></textarea>
\t \t \t <hr />
\t \t \t <!--<p><span class="required">*</span> Are you human?</p>
\t \t \t <label for=verify accesskey=V> 3 + 1 =</label>
\t \t \t <input name="verify" type="text" id="verify" size="4" value="<?php echo $verify; ?>" /><br /><br />-->
\t \t \t <input name="contactus" type="submit" class="submit" id="contactus" value="Submit" />
\t
</div>
\t \t \t </div>
\t \t \t </form>
\t \t \t </fieldset>
<?php }
function isEmail($email) { // Email address verification, do not edit.
return(preg_match("/^[-_.[:alnum:]][email protected]((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));
}
?>
あなたはメールがsmtp経由で送信されるべきであることを意味しますか? – Sepultura
これは恐ろしいコードです...セキュリティの問題がいっぱいです! – arkascha
あなたの質問は完全に不明です。これを間違ってはいけませんが、あなたが実際に何をしているのか分からないかのように読んでいます。意味が分からない文脈で用語を使用します... 'smtp'は電子メールメッセージを送信するプロトコルです。ここでの接続。そして、「どのようにクエリが他の2つのIDに行くべきか」? – arkascha