Can't pass FORM data to PHP file
I had this working for a friend, then he changed provider, and now nothing
works, from all the tests i've made, the submit button should pass the
data to the php file, but when the php file runs it gets nothing.
this is the FORM code on the html file:
<form id="lista" action="lista.php" method="post">
<input name="cf_name" type="text" size="50" hidden="yes" class="obscure">
<input name="cf_email" type="text" size="50" hidden="yes" class="obscure">
<textarea name="cf_message" cols="45" rows="10" hidden="yes"
class="obscure"></textarea>
<input type="image" name="lista" value="Enviar Lista por Email"
src="imagens/lista_email.png" width="40" height="40"
onclick="this.form.elements['cf_message'].value =
lista_mail;this.form.elements['cf_name'].value = prompt('Escreva o seu
nome:', '');this.form.elements['cf_email'].value = prompt('Escreva o
seu email:', '');">
<input name="submit" type="submit" value="Enviar" hidden="yes"
class="obscure">
</form>
before, when he clicked on submit, the popups appear to ask for name and
email, and the php file would get those values, now nothing gets there.
Here is the PHP file:
<?php
if ( isset($_POST['submit']) ) {
$smtpinfo['host'] = 'localhost';
$smtpinfo['port'] = '25';
$smtpinfo['auth'] = true;
$smtpinfo['username'] = 'xxx';
$smtpinfo['password'] = 'xxx';
$nome = $_POST['cf_name'];
$email = $_POST['cf_email'];
$mensagem = $_POST['cf_message'];
require_once "Mail.php";
$body = "Nome: ".$nome;
$body.= "\n";
$body.= nl2br($mensagem);
$headers = array ('From' => $email,
'To' => $smtpinfo["username"],
'Subject' => 'Encomenda Website');
$mail_object = Mail::factory('smtp', $smtpinfo);
$mail = $mail_object->send($smtpinfo["username"], $headers, $body);
if ( PEAR::isError($mail) ) {
echo ("<p>" . $mail->getMessage() . "</p>");
} else {
echo ('<b><font color="FFFF00">Mensagem enviada com sucesso para </b>' .
$email . '<br><br></font>');
}}
?>
this PHP works properly on a contact form on the same site, so is ok, the
problem seems to get the data from html form to php, because he never
passes the "IF POST submit is set", don't know why, because you press the
submit button before arriving to this file.
Can anyone please help? Thank you
No comments:
Post a Comment