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 = "my@email.com";

$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
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.

Edited by requinix
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.