PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am trying to write a script that will email both the user and the site owner when a user registers on the site. Everytime I click submit on the form, it tells me:
[quote]Parse error: syntax error, unexpected T_VARIABLE in /misc/27/000/115/947/6/user/web/incomegains.bravehost.com/IGcreate.php on line 9[/quote]
The line varies according to how I rearrange the code and stuff. These are the lines of code that give me trouble:
$msg = ("Welcome to the Income Gains," . $_POST['FirstName'] . " " . $_POST['LastName'] . "!");
$subject = "Welcome to the Income Gains.";
$MSImsg = "Email: . $_POST['Email']" . "<br>Name: " . $_POST['FirstName'] . " " . $_POS['LastName'] . "<br>Zip: " . $_POST['Zip'] . "<br>Password: " . $_POST['Password'];
$MSIsubj = "New Member";
mail("willyjlyles@yahoo.com", $MSIsubj, $MSImsg);
mail($_POST['Email'], $subject, $msg);
I have checked all the $_POST variables to make sure they're correct for the field name. I have tried the $_POST variables with and without the single quotes in the brackets. I have tried both concatenating the strings like above and just making it all one big line of code in quotations. Nothing I can think of works. Why isn't my code working and what to I do to fix it?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
If you're talking about the missing quotation mark, I've tried every combination of quotations and concatenations I can think of and still got the same error, but now I'm off to the books and google to see what's wrong with it.
Okay I have a guess. (I'm in a computer lab right now, and don't have a web server on which to test this)
In all the examples I found, no $_POST variables were in the mail function, which makes me think that I need to set something else equal to $_POST['Email'] and then pass that to the mail function.
Search for XSS, SQL Injection, etc. That is what is meant when we talk about filtering input. Taking input and directly echoing it or inserting it into a DB is dangerous to say the least.