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 = "...admin@yahoo.com";
$subject = "Message from Digital ......";
$headers = "From: YourName <noreply@..........com>";
$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
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 :-)

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.