Jump to content

Very Simple Form,somthing Is Wrong


ludakriss

Recommended Posts

hi,

 

this is my first post here, i am a php noob.

 

what do i do wrong here?

 

<form method="POST" action="contact.php">

<input type="text" id="email" name="email" size="20" value="E-post" required="required"><br>

<input type="text" id="subject" name="subject" size="20" value="Emne" required="required"><br>

<input type="text" id="message" name="message" size="20" value="Melding" required="required"><br>

<input type="submit" value="Send" name="Submit">

 

 

contact.php:

<?php

 

$recipient = "[email protected]";

$subject = "$_REQUEST['subject']";

$location = "index.php?id=skjemasendt";

$sender = "$_REQUEST['email']";

$message = $_REQUEST['message'];

 

mail($recipient, $subject, $message, $sender);

 

header( "Location: $location" );

?>

Link to comment
https://forums.phpfreaks.com/topic/269554-very-simple-formsomthing-is-wrong/
Share on other sites

what do i do wrong here?

Not tell us about the T_ENCAPSED_AND_WHITESPACE error you were getting. If you're just using a variable then don't put it in strings; if you do put one in strings then make sure you do so correctly.

 

And then you'd say something about not getting mail and we'd point out that the fourth argument to mail() needs to be a proper set of headers - not merely the sender's email address. Check the manual page for an example.

Or even better, as someone would no doubt point out, would be to use a third-party tool like PHPMailer to send emails because they can handle all the little intricacies that may arise.

 

Possibly overlooked might be that you shouldn't just put the sender's email in that aforementioned list of headers because there's a risk of (email) header injection; another problem that the third-party thing would address.

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.