Ciao
Ho creato una pagina web
in cui ho inserito 2 tag "input": oggetto e domanda.
Poi ho inserito un button al cui click viene inviata una mail.
codice:
<form name="form1" method="post" action="contatti.php" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTNAME" id="__EVENTNAME" value="" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
theForm = document.form1;
}
function __doPostBack(eventTarget, eventName) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTNAME.value = eventName;
theForm.submit();
}
}
//]]>
</script>
<table style="heigth:155px; width:400px;"><tr>
<td><span >Oggetto</span></td>
<td colspan="2"><input id="Oggetto" type="text" /></td></tr>
<tr><td><span class="GenericText_0">Domanda</span></td>
<td><textarea id="Domanda" value="Domanda" ></textarea></td><td >
<button id="Invia" type="button" onclick="javascript:__doPostBack('Invia', 'onclick');">Invia</button></td></tr>
</table>
Da codice poi vado ad individuare l'evento con
if($_POST["__EVENTTARGET"] == 'Invia' && $_POST["__EVENTNAME"] == 'onclick')
{
codice per inviare la mail
}
E' questo il modo corretto per effettuare il postback?