Forum Moderators: coopster

Message Too Old, No Replies

PHP form email question....

From a PHP know-nothing...

         

edit_g

1:45 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member


I'm trying to get the contents of a form emailed to an email address. When it's done that I want the user to be directed to a "success page". I've never tried anything in PHP before and I'm lost, lost, lost!

Here is the code:

<?

//Declare the variables
$recipient = "someone@example.com";
$subject = "User Registration Details";
$message = "all $ variables here ";
$subject=$_POST['subject'];

//Contents of form - all variables correspond to
//variables in my form
$name=$_POST['name'];
$email=$_POST['email'];
$country=$_POST['country'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];
$etc=$_POST['etc'];

//mail() function sends the mail
mail($recipient,$subject,$message,$email);

//This line sends to thankyou page when finished
header("Location: http://www.example.com/member_reg_success.htm");
?>

Error message I get is this:

Parse error: parse error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in /home/example/public_html/member_reg.php on line 25

If anyone can help I'll be a very happy, headache free boy.

willybfriendly

1:55 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what is on line 25 (or before it), but, there is no need to call a new thank you page. SImply put your script first above what will be your thank you page.

<?
//mail script here
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Thanks</title>
</head>
<body>
<p>Thank you. You should be receiving an email shortly...</p>
</body>
</html>

One less piece of coding to track bugs in :)

WBF

edit_g

1:57 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks for answering so quick willybfriendly - if I do this, what do I put in the <FORM action=whatever.php method=post>? Do I just put the success page?

Knowles

2:20 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



edit_g yes you just need to point the form to the page with the mail script and the thank you note.

Paul in South Africa

2:26 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



edit_g,

Going back to your original post. Do not put $_POST['fieldname'] in double quotes or you will get an error message.

For example

$message = "The message is: $_POST['fieldname']\n";

will not work and will result in an error message, however

$message = "The message is:" . $_POST['fieldname'] . "\n";

will work fine.

$message = <<<END
The message is $_POST['fieldname']\n
END;

should also work (I think).

edit_g

2:27 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks guys - I followed both your suggestions and it all works now. Thanks. :)

Knowles

2:30 pm on Jun 23, 2003 (gmt 0)

10+ Year Member



Thanks Paul I was just fixen to mention that the quotes might be the issue.. darn work got in the way before I could look at the script!