2014-04-09 64 views
0

我有一個表格,當時正在收集信息並將其發送到我的數據庫,但我也希望將該信息發送到一個電子郵件地址,這意味着我需要另一個表單動作調用,這可能嗎? 所以我有表單可以有多個動作嗎?

<form action="fitting.php" method="post" target="myIframe"> 

,我需要這個相同的形式

<form action="MAILTO:[email protected]" method="post"> 

我現在不,如果這是可能的,但希望得到任何幫助的。

+5

只要把'郵件()'(或你的'的mailto:')後,您( *成功*)查詢,爲什麼有兩種形式?用一塊石頭打了兩篇文章;-) –

+0

它只是一種形式,但我想要發送到數據庫併發送到電子郵件相同的信息。 – user3464354

+0

@ Fred-ii-'mailto'打開您最喜歡的郵件客戶端。 – Jurik

回答

0

不,操作屬性位於表單級別。你需要send the email from your PHP腳本,這也許是可取的。

但是,請注意使用表單的腳本。你可能想要做其中的一個「證明你是人......什麼是A + B的東西:

$right_answer = $_SESSION['human_prompt_answer']; 
if($_POST['human_prompt_answer'] == $right_answer) { 
    mail($to, $subject, $message); 
} 

然後建立表單時:

$a = rand(0,10); 
$b = rand(0,10); 
$_SESSION['human_prompt_answer'] = $a+b; 

// ... then in your HTML: 
<label>What is <?php echo $a;?> + <?php echo $b;?>?</label> 
<input type="text" name="human_prompt_answer" /> 
0

形式:

<form action="fitting.php" method="post" target="myIframe"> 
    <!-- inputs and stuff --> 
</form> 

fitting.php:

<?php 
    // send to database with mysqli, PDO or framework methods 
    // ... 
    mail($to, $subject, $message); 
?> 
相關問題