Page 1 of 1
Form help in php and html
Posted: Sun May 21, 2006 4:18 pm
by akimm
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!!!
Posted: Sun May 21, 2006 4:20 pm
by psychotomus
any output?
Posted: Sun May 21, 2006 4:47 pm
by Chris Corbyn
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] =="")
Posted: Sun May 21, 2006 4:51 pm
by Chris Corbyn
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.
thanks
Posted: Sun May 21, 2006 6:05 pm
by akimm
I will try these fixes hopefully they are enough.
Error
Posted: Sun May 21, 2006 6:11 pm
by akimm
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
Re: Error
Posted: Sun May 21, 2006 6:42 pm
by Chris Corbyn
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.
Posted: Sun May 21, 2006 7:04 pm
by akimm
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]
Posted: Sun May 21, 2006 8:22 pm
by RobertGonzalez
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";
?>
Alrighty
Posted: Sun May 21, 2006 8:25 pm
by akimm
Thanks again, I will try this and see if that does the trick.
another error message
Posted: Sun May 21, 2006 10:07 pm
by akimm
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>
Posted: Mon May 22, 2006 12:00 am
by RobertGonzalez
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>
ah thanks
Posted: Mon May 22, 2006 1:18 am
by akimm
thanks thanks.
Posted: Mon May 22, 2006 1:24 am
by RobertGonzalez
Did it work?
Yes
Posted: Tue May 30, 2006 1:50 pm
by akimm
This has been an ungoing experiment with coding. These two programs you guys helped with are of my first few I have.