Jump to content

How do I?


jon4433

Recommended Posts

I'm using the mail() in my application form, but I can't seem to get the email to send what the user has entered in the form to me.

 

It's been confusing me for hours now!

 

<?php

if($_POST['submit'])
{

$username = $_POST['username'];
$email = $_POST['email'];
$age = $_POST['age'];
$location = $_POST['location'];
$duration = $_POST['duration'];
$griefed = $_POST['griefed'];
$access = $_POST['access'];
$builder = $_POST['builder'];
$fill = $_POST['fill'];

if($username && $email && $age && $location && $duration && $griefed && $access && $builder && $fill){

$to = "[email protected]";
$from = '$email';
$subject = "Creative World Application" ; 
$message = "Username: $username /n" .
			"Email: $email /n" .
			"Age: $age /n" . 
			"Location: $location /n" .
			"Duration on the server: $duration /n" .
			"Ever griefed: $griefed /n" . 
			"Access to the new world: $access /n" . 
			"Are you a good builder: $builder /n" . 
			"Anything else that we should know: $fill /n" .

mail($to, $from, $subject, $message);

echo "Application was sent!";
}
	else
		{
			echo "All fields are required!";
		}
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form method="POST">
<center>
In-Game Name: <input type="text" name="username"/><p>
    Email: <input type="text" name="email" /><p>
    Age: <input type="text" name="age" /><p>
    Location: <input type="text" name="location" /><p>
    How long have you beed on Dawncraft: <input type="text" name="duration" /><p>
    Have you ever griefed: <input type="text" name="griefed" /><p>
    Why do you want access to the creative world: <input type="text" name="access" /><p>
    Do you consider yourself to be a good builder: <input type="text" name="builder" /><p>
    Anything else that we should know: <textarea name="fill"></textarea><p>
    <input type="submit" name="submit" value="Submit" />
    
</center>
</form>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/257197-how-do-i/
Share on other sites

On this line: $from = '$email';, you assign the string literal '$email' to the $from variable. You don't need quotes at all to assign the value of a variable to another variable.

 

The arguments in the mail function aren't right. From: is a header, not an argument by itself.

Link to comment
https://forums.phpfreaks.com/topic/257197-how-do-i/#findComment-1318399
Share on other sites

On this line: $from = '$email';, you assign the string literal '$email' to the $from variable. You don't need quotes at all to assign the value of a variable to another variable.

 

The arguments in the mail function aren't right. From: is a header, not an argument by itself.

 

Hmm, what will I need to do to the mail function? I thought the mail function was correct, but i'm new at php.

 

Do I have this correct, the email sends but the variables inside the of $message do not appear?

 

That is correct. It actually shows the $subject in the message area.

 

 

Also, I like how fast replies are on this forum!

Link to comment
https://forums.phpfreaks.com/topic/257197-how-do-i/#findComment-1318415
Share on other sites

Can't believe that script doesn't have a parse error:

<?php //syntax highlighting.

if($username && $email && $age && $location && $duration && $griefed && $access && $builder && $fill){

$to = "[email protected]";
$from = '$email';
$subject = "Creative World Application" ; 
$message = "Username: $username /n" .
			"Email: $email /n" .
			"Age: $age /n" . 
			"Location: $location /n" .
			"Duration on the server: $duration /n" .
			"Ever griefed: $griefed /n" . 
			"Access to the new world: $access /n" . 
			"Are you a good builder: $builder /n" . 
			"Anything else that we should know: $fill /n" .  //<- You need to remove the . (period) and place a ; (semicolon).

mail($to, $from, $subject, $message);

Link to comment
https://forums.phpfreaks.com/topic/257197-how-do-i/#findComment-1318427
Share on other sites

Can't believe that script doesn't have a parse error:

<?php //syntax highlighting.

if($username && $email && $age && $location && $duration && $griefed && $access && $builder && $fill){

$to = "[email protected]";
$from = '$email';
$subject = "Creative World Application" ; 
$message = "Username: $username /n" .
			"Email: $email /n" .
			"Age: $age /n" . 
			"Location: $location /n" .
			"Duration on the server: $duration /n" .
			"Ever griefed: $griefed /n" . 
			"Access to the new world: $access /n" . 
			"Are you a good builder: $builder /n" . 
			"Anything else that we should know: $fill /n" .  //<- You need to remove the . (period) and place a ; (semicolon).

mail($to, $from, $subject, $message);

 

It did have a semicolon before I posted the thread. I was testing to try and get them to include each other, but I guess it didn't work, but i'll be changing them back to a semicolon soon!

Link to comment
https://forums.phpfreaks.com/topic/257197-how-do-i/#findComment-1318429
Share on other sites

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.