Jump to content

PHP code and form code problem


Hobo

Recommended Posts

First let me say that I didn't write this php code. I am trying to implement this php file and a "Join our mailing list" form. I can not see what's wrong so I am asking for some help. When I click the submit button on the web page I get:

 

"File Download" ....Do you want to "Open" "Save" "Cancel"

 

For the life of me I can not see why the form code and the .php code are not meshing?

I have attached the .php code and the form code, if someone could take a look at them and tell me (or point me in the right direction) where I made my error(s) , I would appreciate it.

 

Thanks in advance!

 

 

 

PHP code

 

 

<?PHP 

if($_POST['submit']) 

{ 

$recipient="[email protected]"; 

$subject="Contact from Shoals Bend Web Site"; 

$body=" 

$name 

$email 

  

"; 

$headers='From: '.$email."\r\n".'Reply-to: '.$email."\r\n"; 

mail($recipient, $subject, $body, $headers); 

echo " 

<script> 

alert('Your message has been submitted. Thank You!'); 

window.location='index.html'; 

</script>"; 

} 

else 

{ 

echo " 

<script> 

window.location='index.html'; 

</script>"; 

} 

?> 

 

 

Below is the Form code.

 

<title>Untitled Document</title>
<style type="text/css">
<!--
form {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 11px;
font-weight: normal;
text-decoration: none;
}
button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
border: 1px solid #FFFFFF;
}
button {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
}
-->
</style>
</head>

<body>
<form action="sendmail2.php" method="post" name="untitled-3" id="untitled-3">
  <table width="63%" border="2" cellpadding="4">
    <tr>
      <td width="36%"><strong>Join Our Mailing List</strong> </td>
      <td width="64%"> </td>
    </tr>
    <tr>
      <td>Name</td>
      <td><input name="name" type="text" id="name" /></td>
    </tr>
    <tr>
      <td>Email</td>
      <td><input name="email" type="text" id="email" /></td>
    </tr>
    <tr>
      <td>Comments</td>
      <td><p>
        <textarea name="comments" id="comments"></textarea>
      </p>
      <p>  </p></td>
    </tr>
    <tr>
      <td height="34"> </td>
      <td><input type="submit" name="Submit" value="Submit" />
      <input type="reset" name="Submit2" value="Clear" /></td>
    </tr>
  </table>
</form>

 

Any help?

Link to comment
https://forums.phpfreaks.com/topic/143266-php-code-and-form-code-problem/
Share on other sites

Two things.  One you are not populating your variables, unless you have register globals turned on.

 

Two, check your server log to see if it's failing because of the missing FROM: header, and also this may need to be a valid email on your domain and not the senders.

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.