Jump to content

Contact form script not sending fields


g7labs

Recommended Posts

Hi, i have a script problem as I am a graphic designer with zero php knowledge.  I have a contact script that sends emails but they are blank. Meaning all text fields are not sending. If you could correct this for me thanks in advance. Here is my hacked up script that sends email with empty fields:
 
<!DOCTYPE html>
<html lang="en">


<?php
if (!count($_POST)){
?> 


<form method="post" id="myform" action="<?php echo $_SERVER['PHP_SELF']; ?>">


</form>
               <?php
}else{
   ?>
        


<?php
$mail = $_POST['email'];


/*$subject = "".$_POST['subject'];*/
$to = "[email protected]";
$subject = "Message from Digital ......";
$headers = "From: YourName <[email protected]>";
$message = "Message from YourName\n";
$message .= "\nName: " . $_POST['Name'];
$message .= "\nEmail: " . $_POST['Email'];
$message .= "\nMessage: " . $_POST['Message'];




//Receive Variable
$sentOk = mail($to,$subject,$message,$headers);
}
?>


<!-- END SEND MAIL SCRIPT -->   


</html>

This is all that sends:

 

Message from YourName
Name: 
Email: 
Message: 

Link to comment
https://forums.phpfreaks.com/topic/291427-contact-form-script-not-sending-fields/
Share on other sites

I only see <form></form>. Where are the input fields?

 

the index for the $_POST array has to be the same as the name attribute inside your input fields and are case sensitive.

 

eg: <input type="text" name="email" />   <==>   $_POST['email']

 

And to be honest: your code is a nightmare :-)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.