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!
Moderator: General Moderators
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 4:18 pm
Alright I have this form set to reside on a page and send a users info to me I cannot understand where I've gone wrong, I've trouble shot this code for a while and I'm stumped, can anyone help?
Code: Select all
<form action="send_word.php" method="POST">
<p><b>your name</b>
<input type="text" name="name" size="30"></p>
<p><b>your email</b>
<input type="text" name="sender_email" size="30"></p>
<p><b>your word</b>
<input type="text" name="word" size="30"></p>
<p><b>definition</b>
<TEXTAREA NAME="definition" COLS="30" ROWS="5"
WRAP="virtual"></TEXTAREA></P>
<p><input type="submit" name="submit" value="send your word!"></p>
<?php
if ($_POST[name] == "" ||
($_POST[sender_email] == "" ||
($_POST[word] == "" ||
($_POST[definition] =="")
$msg = 'E-MAIL SENT FROM THE CLAIRICTIONARY\n';
$msg .= "Sender's NAME: \t$_POST[name]\n";
$msg .= "Sender's EMAIL:\t$_POST[sender_email]\n";
$msg .= "Sender's WORD:\t$_POST[WORD]\n";
$msg .= "Sender's definition:\t$_POST[definition]\n";
$to = "dailylifez@yahoo.com";
$subject = "Clairictionary words";
$mailtoheaders = "From: Akimm <Sean@akimm.com>\n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n";
mail($to, $subject, $msg, $mailheaders);
?>
<html>
<head>
</head>
<body>
<h1> the following email has been sent!</h1>
<P><b>Your Name:</b><br>
<? echo "$_POST[name]"; ?>
<P><b>Your E-Mail Address:</b><br>
<? echo "$_POST[sender_email]"; ?>
<P><b>Message:</b><br>
<? echo "$_POST[word]"; ?>
<P><b>definition:</b><br>
<? echo "$_POST[definition]"; ?>
</body>
</html>
the html is here
Code: Select all
<form action="send_simpleform.php" method="POST">
<p><b>your name</b>
<input type="text" name="name" size="30"></p>
<p><b>your email</b>
<input type="text" name="sender_email" size="30"></p>
<p><b>your word</b>
<input type="text" name="word" size="30"></p>
<p><b>definition</b>
<TEXTAREA NAME="definition" COLS="30" ROWS="5"
WRAP="virtual"></TEXTAREA></P>
<p><input type="submit" name="submit" value="send your word!"></p>
Thanks for any help provided!!!
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun May 21, 2006 4:47 pm
There's all kinds of things wrong with this. Firstly you should place your array keys in quotes if they are strings:
Secondly this:
Code: Select all
if ($_POST[name] == "" ||
($_POST[sender_email] == "" ||
($_POST[word] == "" ||
($_POST[definition] =="")
Is worng... there;s parentheses all over the place and unbalanced there.... maybe?
Code: Select all
if ($_POST[name] == "" ||
$_POST[sender_email] == "" ||
$_POST[word] == "" ||
$_POST[definition] =="")
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun May 21, 2006 4:51 pm
Also, your "if" statement will only execute the first line underneath it unless you use curly braces to mark out a whole block of statements:
Code: Select all
<?php
if ($_POST['name'] != "" &&
$_POST['sender_email'] != "" &&
$_POST['word'] != "" &&
$_POST['definition'] !="")
{
$msg = 'E-MAIL SENT FROM THE CLAIRICTIONARY\n';
$msg .= "Sender's NAME: \t$_POST[name]\n";
$msg .= "Sender's EMAIL:\t$_POST[sender_email]\n";
$msg .= "Sender's WORD:\t$_POST[word]\n";
$msg .= "Sender's definition:\t$_POST[definition]\n";
$to = "dailylifez@yahoo.com";
$subject = "Clairictionary words";
$mailtoheaders = "From: Akimm <Sean@akimm.com>\n";
$mailheaders .= "Reply-To: $_POST[sender_email]\n";
mail($to, $subject, $msg, $mailheaders);
}
?>
And lastly I think you need && not || because you want all of those fields complete in order to submit that info.
EDIT | Also, the array keys and variable names are case sensitive so WORD whould be lowercase.
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 6:05 pm
I will try these fixes hopefully they are enough.
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 6:11 pm
Parse error: parse error, unexpected T_VARIABLE in /nfs/cust/8/25/05/650528/web/clairictionary/send_simpleform.php on line 23
after the fixes you so kindly provided, I'm lost as to what this error even means let alone where the problem is consistent
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun May 21, 2006 6:42 pm
akimm wrote: Parse error: parse error, unexpected T_VARIABLE in /nfs/cust/8/25/05/650528/web/clairictionary/send_simpleform.php on line 23
after the fixes you so kindly provided, I'm lost as to what this error even means let alone where the problem is consistent
Can you post the code the way it looks now please? Including line 23.
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 7:04 pm
Code: Select all
[php]
<form action="send_word.php" method="POST">
<p><b>your name</b>
<input type="text" name="name" size="30"></p>
<p><b>your email</b>
<input type="text" name="sender_email" size="30"></p>
<p><b>your word</b>
<input type="text" name="word" size="30"></p>
<p><b>definition</b>
<TEXTAREA NAME="definition" COLS="30" ROWS="5"
WRAP="virtual"></TEXTAREA></P>
<p><input type="submit" name="submit" value="send your word!"></p>
<?php
if ($_POST['name'] != "" &&
$_POST['sender_email'] != "" &&
$_POST['word'] != "" &&
$_POST['definition'] !="")
{
$msg = 'E-MAIL SENT FROM THE CLAIRICTIONARY\n';
$msg .= "Sender's NAME: \t$_POST['name']\n";
$msg .= "Sender's EMAIL:\t$_POST['sender_email']\n";
$msg .= "Sender's WORD:\t$_POST['word']\n";
$msg .= "Sender's definition:\t$_POST['definition']\n";
$to = "dailylifez@yahoo.com";
$subject = "Clairictionary words";
$mailtoheaders = "From: Akimm <Sean@akimm.com>\n";
$mailheaders .= "Reply-To: $_POST['sender_email']\n";
mail($to, $subject, $msg, $mailheaders);
}
?>
<html>
<head>
</head>
<body>
<h1> the following email has been sent!</h1>
<P><b>Your Name:</b><br>
<? echo "$_POST['name']"; ?>
<P><b>Your E-Mail Address:</b><br>
<? echo "$_POST['sender_email']"; ?>
<P><b>Message:</b><br>
<? echo "$_POST['word']"; ?>
<P><b>definition:</b><br>
<? echo "$_POST['definition']"; ?>
</body>
</html>
[/php]
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sun May 21, 2006 8:22 pm
Anywhere you see something like this...
Code: Select all
<?php
$msg .= "Sender's NAME: \t$_POST['name']\n";
?>
Change it to something like...
Code: Select all
<?php
$msg .= "Sender's NAME: \t" . $_POST['name'] . "\n";
// OR this...
$msg .= "Sender's NAME: \t{$_POST['name']}\n";
?>
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 8:25 pm
Thanks again, I will try this and see if that does the trick.
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Sun May 21, 2006 10:07 pm
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /nfs/cust/8/25/05/650528/web/clairictionary/send_simpleform.php on line 32
Code: Select all
<form action="send_word.php" method="POST">
<p><b>your name</b>
<input type="text" name="name" size="30"></p>
<p><b>your email</b>
<input type="text" name="sender_email" size="30"></p>
<p><b>your word</b>
<input type="text" name="word" size="30"></p>
<p><b>definition</b>
<TEXTAREA NAME="definition" COLS="30" ROWS="5"
WRAP="virtual"></TEXTAREA></P>
<p><input type="submit" name="submit" value="send your word!"></p>
<?php
if ($_POST['name'] != "" &&
$_POST['sender_email'] != "" &&
$_POST['word'] != "" &&
$_POST['definition'] !="")
{
$msg = 'E-MAIL SENT FROM THE CLAIRICTIONARY\n';
$msg .= "Sender's NAME: \t{$_POST['name']}\n";
$msg .= "Sender's EMAIL:\t{$_POST['sender_email']}\n";
$msg .= "Sender's WORD:\t{$_POST['word']}\n";
$msg .= "Sender's definition:\t{$_POST['definition']}\n";
$to = "dailylifez@yahoo.com\n";
$subject = "Clairictionary words\n";
$mailtoheaders = "From: Akimm <Sean@akimm.com>\n";
$mailheaders .= "Reply-To: $_POST['sender_email']\n";
mail($to, $subject, $msg, $mailheaders);
}
?>
<html>
<head>
</head>
<body>
<h1> the following email has been sent!</h1>
<P><b>Your Name:</b><br>
<? echo "$_POST['name']"; ?>
<P><b>Your E-Mail Address:</b><br>
<? echo "$_POST['sender_email']"; ?>
<P><b>Message:</b><br>
<? echo "$_POST['word']"; ?>
<P><b>definition:</b><br>
<? echo "$_POST['definition']"; ?>
</body>
</html>
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Mon May 22, 2006 12:00 am
Sorry, should have been more specific. I meant anywhere a global/array var was used within double quotes either concatenate the variable or wrap it in curly braces({}). Try this and see if it works...
Code: Select all
<form action="send_word.php" method="POST">
<p><b>your name</b>
<input type="text" name="name" size="30"></p>
<p><b>your email</b>
<input type="text" name="sender_email" size="30"></p>
<p><b>your word</b>
<input type="text" name="word" size="30"></p>
<p><b>definition</b>
<TEXTAREA NAME="definition" COLS="30" ROWS="5"
WRAP="virtual"></TEXTAREA></P>
<p><input type="submit" name="submit" value="send your word!"></p>
<?php
if ($_POST['name'] != "" &&
$_POST['sender_email'] != "" &&
$_POST['word'] != "" &&
$_POST['definition'] !="")
{
$msg = "E-MAIL SENT FROM THE CLAIRICTIONARY\n";
$msg .= "Sender's NAME: \t{$_POST['name']}\n";
$msg .= "Sender's EMAIL:\t{$_POST['sender_email']}\n";
$msg .= "Sender's WORD:\t{$_POST['word']}\n";
$msg .= "Sender's definition:\t{$_POST['definition']}\n";
$to = "dailylifez@yahoo.com\n";
$subject = "Clairictionary words\n";
$mailtoheaders = "From: Akimm <Sean@akimm.com>\n";
$mailheaders .= "Reply-To: {$_POST['sender_email']}\n";
mail($to, $subject, $msg, $mailheaders);
}
?>
<html>
<head>
</head>
<body>
<h1> the following email has been sent!</h1>
<P><b>Your Name:</b><br>
<?php echo $_POST['name']; ?>
<P><b>Your E-Mail Address:</b><br>
<?php echo $_POST['sender_email']; ?>
<P><b>Message:</b><br>
<?php echo $_POST['word']; ?>
<P><b>definition:</b><br>
<?php echo $_POST['definition']; ?>
</body>
</html>
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Mon May 22, 2006 1:18 am
thanks thanks.
akimm
Forum Contributor
Posts: 460 Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh
Post
by akimm » Tue May 30, 2006 1:50 pm
This has been an ungoing experiment with coding. These two programs you guys helped with are of my first few I have.