Jump to content

Recommended Posts

Hi,

I have the following code:

[code]<form action="send.php">
<b>Full Name:</b><br>
<input type="text" name="name" size="25" value="">
<br><br>
    
<b>Email Address:</b><br>
<input type="text" name="email" size="25" value="">
<br><br>

<b>Subject:</b><br>
<input type="text" name="subject" size="35" value="">
<br><br>

<b>Message:</b><br>
<textarea name="message" cols="35" rows="6"></textarea>
<br><br>

<input type="submit" />
</form>[/code]

Send.php:
[code]<?php

$name = $HTTP_POST_VARS['name'];
$email = 'From: '.$HTTP_POST_VARS['email'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];


$to = 'jibberish@you.com';
$body = 'Name: '.$name.'\n'
.'E-Mail Address: '.$email.'\n'
.'Message: \n \n'.$message;

mail($to, $subject, $body, $email);
?> [/code]

This is the email I get it:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Name: \nE-Mail Address: From: \nMessage: \n \n
[/quote]

Whats wrong?

Thanks. :)
Link to comment
https://forums.phpfreaks.com/topic/4926-php-form-help/
Share on other sites

What's wrong? Alot...

Read the comments in the following fixed code:
[code]<?php
$name = $_POST['name'];  // use the superglobal $_POST
$email = 'From: '.$_POST['email'] . "\n";  // headers need to be terminated with a new-line character
$subject = striplashes($_POST['subject']); // use stripslashes or your email message may be peppered with backslashes
$message = stripslashes($_POST['message']);  // same as above


$to = 'jibberish@you.com';
$body = 'Name: '.$name."\n"
.'E-Mail Address: '.$email."\n"
."Message: \n \n".$message;  // the newline character needs to be surrounded by double quotes or it won't be inserted correctly

mail($to, $subject, $body, $email);
?>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/4926-php-form-help/#findComment-17368
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.