RE: [HELP] Website Functions! 12-15-2013, 06:40 PM
#11
![[Image: 635111b0ff02f69fd9f5a56a1ae8aa4a.png]](http://gyazo.com/635111b0ff02f69fd9f5a56a1ae8aa4a.png)
It doesn't seem to work.
| [HELP] Website Functions! filter_list | |
<td><input type="text" name="email"></td><td><textarea type="text" name="message"><form method="post" name="contact" id="contact">
<table>
<tr>
<td>Your Email Address</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject</td>
<td><textarea type="text" name="subject"></textarea></td>
</tr>
<tr>
<td>Your Message</td>
<td><textarea type="text" name="message"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form><?php
$mail = $_POST['email'];
$to = 'cbc-chat@hotmail.com';
$subject = 'Contact Form:' . $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $mail . "\r\n" .
'Reply-To: ' . $mail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>![[Image: tumblr_m73y8go3jd1rb7u8co1_500.gif]](http://24.media.tumblr.com/tumblr_m73y8go3jd1rb7u8co1_500.gif)
(12-15-2013, 07:02 PM)Anizeb Wrote: There are a number of things wrong here.
andCode:<td><input type="text" name="email"></td>
Code:<td><textarea type="text" name="message">
are the two things you need to snatch from the orm you've got. You should also include a subject field, or a name one as CamIce seems to have implied. (I've done so below)
So what you want (combining both you and CamIce's code) would be
Code:<form method="post" name="contact" id="contact"> <table> <tr> <td>Your Email Address</td> <td><input type="text" name="email"></td> </tr> <tr> <td>Subject</td> <td><textarea type="text" name="subject"></textarea></td> </tr> <tr> <td>Your Message</td> <td><textarea type="text" name="message"></textarea></td> </tr> <tr> <td><input type="submit" value="Submit" /></td> </tr> </table> </form>
Code:<?php $mail = $_POST['email']; $to = 'cbc-chat@hotmail.com'; $subject = 'Contact Form:' . $_POST['subject']; $message = $_POST['message']; $headers = 'From: ' . $mail . "\r\n" . 'Reply-To: ' . $mail . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?>
Untested, and it's been ages since I've used PHP, so I may have fucked up. Sorry in advance, if that's the case.
<form method="post" name="contact" id="contact" action="send.php">
<table>
<tr>
<td>Your Email Address</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject</td>
<td><textarea type="text" name="subject"></textarea></td>
</tr>
<tr>
<td>Your Message</td>
<td><textarea type="text" name="message"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form>![[Image: tumblr_m73y8go3jd1rb7u8co1_500.gif]](http://24.media.tumblr.com/tumblr_m73y8go3jd1rb7u8co1_500.gif)
(12-15-2013, 07:26 PM)Anizeb Wrote: Have you moved the PHP to another page?
Makes things easier.
Code:<form method="post" name="contact" id="contact" action="send.php"> <table> <tr> <td>Your Email Address</td> <td><input type="text" name="email"></td> </tr> <tr> <td>Subject</td> <td><textarea type="text" name="subject"></textarea></td> </tr> <tr> <td>Your Message</td> <td><textarea type="text" name="message"></textarea></td> </tr> <tr> <td><input type="submit" value="Submit" /></td> </tr> </table> </form>
and you now add the PHP to a file called "send.php"
Only mentioning this because your form originally submitted to itself, and I didn't know if you set up the page right.
<form action="email.php" method="post" name="contact" id="contact">
<table>
<tr>
<td>Your Email Address</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject</td>
<td><textarea type="text" name="subject"></textarea></td>
</tr>
<tr>
<td>Your Message</td>
<td><textarea type="text" name="message"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form><?php
$mail = $_POST['email'];
$to = 'cbc-chat@hotmail.com';
$subject = 'Contact Form:' . $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $mail . "\r\n" .
'Reply-To: ' . $mail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>![[Image: tumblr_m73y8go3jd1rb7u8co1_500.gif]](http://24.media.tumblr.com/tumblr_m73y8go3jd1rb7u8co1_500.gif)
(12-15-2013, 07:35 PM)Anizeb Wrote: OH, I see. Also, I've tested it, and it works as intended.
"contact" is the name of the form, and that's irrelevant.
You need the field names, not the form name,
What exactly is the behavior you're looking for, if that code isn't what you need?
Because it does grab from POST just fine.
(12-15-2013, 07:35 PM)Anizeb Wrote: OH, I see. Also, I've tested it, and it works as intended.
"contact" is the name of the form, and that's irrelevant.
You need the field names, not the form name,
What exactly is the behavior you're looking for, if that code isn't what you need?
Because it does grab from POST just fine.
![[Image: c43b97f754cd80aebb266143ed368183.png]](http://gyazo.com/c43b97f754cd80aebb266143ed368183.png)
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'cbc-chat@hotmail.com';
$subject = 'Message from a site visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to cbc-chat@hotmail.com');
window.location = 'contact.html';
</script>
<?php
}
?><form method="post" name="contact" id="contact" action="send.php">
<table>
<tr>
<td>Your Email Address</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Subject</td>
<td><textarea type="text" name="subject"></textarea></td>
</tr>
<tr>
<td>Your Message</td>
<td><textarea type="text" name="message"></textarea></td>
</tr>
<tr>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
</form><?php
$mail = $_POST['email'];
$to = '[CENSORED]';
$subject = 'Contact Form:' . $_POST['subject'];
$message = $_POST['message'];
$headers = 'From: ' . $mail . "\r\n" .
'Reply-To: ' . $mail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
echo $to . " " . $subject . " " . $message . " " . $headers;
?>![[Image: tumblr_m73y8go3jd1rb7u8co1_500.gif]](http://24.media.tumblr.com/tumblr_m73y8go3jd1rb7u8co1_500.gif)
(12-15-2013, 08:05 PM)Anizeb Wrote: This is the (near) exact code I've used:
mail.htm
Code:<form method="post" name="contact" id="contact" action="send.php"> <table> <tr> <td>Your Email Address</td> <td><input type="text" name="email"></td> </tr> <tr> <td>Subject</td> <td><textarea type="text" name="subject"></textarea></td> </tr> <tr> <td>Your Message</td> <td><textarea type="text" name="message"></textarea></td> </tr> <tr> <td><input type="submit" value="Submit" /></td> </tr> </table> </form>
send.php
Code:<?php $mail = $_POST['email']; $to = '[CENSORED]'; $subject = 'Contact Form:' . $_POST['subject']; $message = $_POST['message']; $headers = 'From: ' . $mail . "\r\n" . 'Reply-To: ' . $mail . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); echo $to . " " . $subject . " " . $message . " " . $headers; ?>
and that is functional, and sending me emails. Obviously, I've removed mine, but it's a LIVE.com email, so if it works there, it should work for you.
For you, I imagine your if-else might be an issue. Either that, or you forgot to rename the fields in your form to match the PHP.
Stick with something simple like mine, and work SLOWLY towards what you want.
Also, this WILL end up in your spam folder, so make sure you check out that it's not an issue with that.
Edit;
Your code works fine, as long as the field names match.
It's also possible that your server has disallowed mailing for some reason, but I'm leaning towards the field thing, considering you seem to have a little trouble understanding how to properly use POST.
![[Image: tumblr_m73y8go3jd1rb7u8co1_500.gif]](http://24.media.tumblr.com/tumblr_m73y8go3jd1rb7u8co1_500.gif)