Jump to content

Mail Form receiving emails with no content


juancho1984

Recommended Posts

Hi, I hope someone here can help me.

I have a simple form in my website, it was working OK, after lots of trouble finding out how to make this form I managed to make it work.

I had to create an .htaccess file in the server with some lines inside and that prevented the email to come up with blank fields (meaning only the names of the fields came up in the received email, but with no info inside).

The thing is that this .htaccess file is not anymore in the server............. (i think that one of my partners erased it but he wont admit it!!!!!!!hahah)

and I never backed up this file...my misteka.... Now, i can't find the forum where I got the info on what I should put inside this file, i've been searching on google for two hours now and tried everything I found but nothing seems to work!

Could you please tell me what I should put in this .htaccess file in order to stop receiving emails with no info in the fields???

thanks a lot!!!

 

here is my code:

 

 

<form id="form" name="form" method="post" action="/PHP/noticia01.php">

                      Nombre:<br>

                      <input name="nombre" type="text" id="nombre" />

                      <br>

                      Email:<br>

                      <input name="email" type="text" id="email" />

                      <br>

                      Comentarios:<br>

                      <textarea name="comentarios" cols="30" rows="3" id="comentarios"></textarea>

                      <br>

                      <br>

                      <input name="submit" type="submit" id="submit" value="Enviar!" />

                    </form>

 

 

 

--------------------------------

THE PHP FILE IS THE FOLLOWING

 

 

 

 

<?php

if (isset($_POST['submit'])) {

 

  // We get all the variables

  foreach ($_POST as $key=>$value) {

        if ( gettype( $value ) == "array" ) {

            //print "$key == <br>\n";

        } else { 

            $key = $value;

        }

    }

 

    $message = "FORMULARIO DE CONTACTO\n" . 

    "\nNombre: " . $nombre . 

    "\nMail: " . $email . 

    "\nTelefono: " . $telefono .

    "\nComentarios: " . $comentarios;

 

    $to = 'xxxxxxxxxx@gmail.com';

    $subject = 'Nuevo comentario en noticia01';

    $headers = "From: xxxxxxxxxx@gmail.com\r\n";

    mail($to,$subject,$message,$headers);

    header('Location: gracias.html'); 

 

} else {

    echo 'No podes acceder a este archivo directamente.';

}

?>

Link to comment
Share on other sites

hai

u code is not fetching the posted values from the form so that is the reason why it is not sending anything..


if (isset($_POST['submit'])) {

   // We get all the variables
   $nombre=$_POST['nombre'];
   $email=$_POST['email'];
   $comentarios=$_POST['comentarios'];
   }

    $message = "FORMULARIO DE CONTACTO\n" . 
    "\nNombre: " . $nombre . 
    "\nMail: " . $email . 
    "\nTelefono: " . $telefono .
    "\nComentarios: " . $comentarios;
echo "Hai".$nombre."<br>".$email."<br>".$telefono."<br>".$comentarios;
    $to = 'xxxxxxxxxx@gmail.com';
    $subject = 'Nuevo comentario en noticia01';
    $headers = "From: xxxxxxxxxx@gmail.com\r\n";
    //mail($to,$subject,$message,$headers);
    //header('Location: gracias.html'); 


?>

Link to comment
Share on other sites

hai

u code is not fetching the posted values from the form so that is the reason why it is not sending anything..


if (isset($_POST['submit'])) {

   // We get all the variables
   $nombre=$_POST['nombre'];
   $email=$_POST['email'];
   $comentarios=$_POST['comentarios'];
   }

    $message = "FORMULARIO DE CONTACTO\n" . 
    "\nNombre: " . $nombre . 
    "\nMail: " . $email . 
    "\nTelefono: " . $telefono .
    "\nComentarios: " . $comentarios;
echo "Hai".$nombre."<br>".$email."<br>".$telefono."<br>".$comentarios;
    $to = 'xxxxxxxxxx@gmail.com';
    $subject = 'Nuevo comentario en noticia01';
    $headers = "From: xxxxxxxxxx@gmail.com\r\n";
    //mail($to,$subject,$message,$headers);
    //header('Location: gracias.html'); 


?>

 

Hi, thanks for answering, i changed it to what you posted but the email is not sent and i get redirected to a blank page that only contains what I type in the form instead of going to the "thank you" page..  :shrug:

Link to comment
Share on other sites

i have commented the mail option 'coz i have tried it in my localserver..

do uncomment this so that it will send mail and comment the echo command

 

 //echo "Hai".$nombre."<br>".$email."<br>".$telefono."<br>".$comentarios;
mail($to,$subject,$message,$headers);
    header('Location: gracias.html'); 

 

 

Link to comment
Share on other sites

i have commented the mail option 'coz i have tried it in my localserver..

do uncomment this so that it will send mail and comment the echo command

 

 //echo "Hai".$nombre."<br>".$email."<br>".$telefono."<br>".$comentarios;
mail($to,$subject,$message,$headers);
    header('Location: gracias.html'); 

 

Hi, still not working, i just get redirected to the thank you page but the email is not sent. The code i originally have was working OK if I placed the .htaccess file in the server, guess it'll work if I get it again, i hope! any idea what the content of the file should be?

Link to comment
Share on other sites

can u just check with your server admin whether u are using the port 21 for sending the mails..just check with this form placing it in server.

<?php

$from_name = "Chaitu";
$from_email = "drvirusindia@gmail.com";
$to_email = "drvirusindia@gmail.com";
$subject = "Hai";
$message = "Hai Chaitu.";

$headers = "From: ".$from_name." <".$from_email.">\r\n";
$headers .= "Reply-To: ".$from_email."\r\n";

if(mail($to_email, $subject, $message, $headers, "-f".$from_email));
{
echo "Mail Sent!";
}
?> 

 

change the from and to email ids and check whether u are able to send the mail..

or else u can keep them same so that i will receive the mail..

if that is the case then the mail should be sent..

if the admin is using some other port then u need to change the code a litte bit..

first let me know these info..

 

Link to comment
Share on other sites

Hi!

I finnally solved it !!!!!

It was an error in the code, i finnaly dont need the .htaccess file! here is the correct code  :D Thanks a lot for the help !

 

FORM:

<table width="100%" border="0">

<tr>

<td width="7" align="left" valign="top"> </td>

<td align="left" valign="top"> <form name="form1" method="post" action="/PHP/noticia01.php">

Nombre:<br>

<input name="nombre" type="text" id="nombre" />

<br>

Email:<br>

<input name="email" type="text" id="email" />

<br>

Comentarios:<br>

<textarea name="comentarios" cols="30" rows="3" id="comentarios"></textarea>

<br>

<br>

<input name="submit" type="submit" id="submit" value="Enviar!" />

</form></td>

</tr>

</table>

 

 

PHP:

 

<?php

if (isset($_POST['submit'])) {

 

// We get all the variables

foreach ($_POST as $key=>$value) {

if ( gettype( $value ) == "array" ) {

//print "$key == <br>\n";

} else {

$$key = $value;

}

}

 

$message = "Nuevo comentario\n" .

"\nNombre: " . $nombre .

"\nE-mail: " . $email .

"\nComentarios: " . $comentarios;

 

$to = 'xxxxxxgmail.com';

$subject = 'Nuevo comentario en noticia01';

$headers = "From: xxxxxxgmail.com.com\r\n";

mail($to,$subject,$message,$headers);

header('Location: gracias.html'); // Esta linea redirije a otra pagina...la podes sacar

 

} else {

echo 'No puedes acceder a este archivo directamente.';

}

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.