Results 1 to 24 of 24
Thread: Email form?
Hybrid View
-
06-13-2004, 05:45 PM #1Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
Email form?
Long time ago I used that mailto:emailaddress, and I put that into FORM tag, and it used to open up my email and all the text from the form was inserted into message. Now when I create it like that, all the text from form doesn't show up in the message. I've also tried many php and perl email form scripts, but none of them send. I have no idea what's wrong with it. Any help?
-
06-13-2004, 06:17 PM #2
Not enough info to help with a script.
What script?
What happens?
Any errors?
That sort of thing.
-
06-13-2004, 06:36 PM #3Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
When I tried to use just html and mailto, everything goes perfect but on the form is has like name, address, etc. and it only inserts TO:, and leaves the message box blank. It doesn't add name=blah blah, address=blah blah, etc. in the message box.
But here is the code from the script:
PHP Code:<?php
if ($submit) { // if the form was sent do the following
if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
mail("myemail@myhost.com","From: $name <$email>") or die("email
error");
echo "Message Sent"; // if all went well, display message was sent
} else {
echo "All fields must be filled in!<BR>"; // if not all were filled in, display error message
}
} // end php submission code
?>
-
06-13-2004, 07:02 PM #4Web Hosting Master
- Join Date
- Mar 2004
- Location
- USA
- Posts
- 4,345
Download free sample forms:
Contact Form-- Free PHP ScriptsTesting 1.. Testing 1..2.. Testing 1..2..3...
-
06-13-2004, 07:05 PM #5Web Hosting Master
- Join Date
- Mar 2004
- Location
- USA
- Posts
- 4,345
it also has a nice tutorial to apply
peace,Testing 1.. Testing 1..2.. Testing 1..2..3...
-
06-13-2004, 07:09 PM #6Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
That form has big code, it'll take too long to edit.
-
06-13-2004, 07:43 PM #7Originally posted by WHTer
When I tried to use just html and mailto, everything goes perfect but on the form is has like name, address, etc. and it only inserts TO:, and leaves the message box blank. It doesn't add name=blah blah, address=blah blah, etc. in the message box.
But here is the code from the script:
PHP Code:<?php
if ($submit) { // if the form was sent do the following
if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
mail("myemail@myhost.com","From: $name <$email>") or die("email
error");
echo "Message Sent"; // if all went well, display message was sent
} else {
echo "All fields must be filled in!<BR>"; // if not all were filled in, display error message
}
} // end php submission code
?>
Does it have the action set to post to this same page?
Are the fields in your form named just like you see in the PHP fields ($name, $address)?
Is this page parsed by PHP (typically requires being named something like "page.php", not "page.html")
Could you post a link to the actual page where this is located?
-
06-13-2004, 09:31 PM #8Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
ok, I've made seperate html and php files. But when I fill out the form and click submit, this message comes.
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/atth4y/public_html/shop/sendmail.php on line 2
Parse error: parse error, unexpected T_STRING in /home/atth4y/public_html/shop/sendmail.php on line 2
PHP Code:<?php
if ($submit) { // if the form was sent do the following
if($name && $address && $city && $state && $zipcode && $order && $paymentmethod && $email && $comments) { // if all fields were filled-in send email
$subject="Order";
$msg = $name . "\n" . $address . "\n" . $city . "\n" . $state . "\n" . $zipcode . "\n" . $order . "\n" . $paymentmethod . "\n" . $email . "\n" . $comments;
mail("haris3636@hotmail.com","From: $name <$email>", $subject, $msg);
mail($to,"From: $name <$email>",$subject,$message) or die("email
error");
echo "Message Sent"; // if all went well, display message was sent
} else {
echo "All fields must be filled in!<BR>"; // if not all were filled in, display error message
}
} // end php submission code
?>
-
06-13-2004, 10:17 PM #9WHT Addict
- Join Date
- Aug 2003
- Location
- PA
- Posts
- 110
A big problem, and especially if you cut and pasted this, is that all of your form variables, since you are using the POST method, must be like this $_POST['form_field_name']. Otherwise, you will have stuff going wrong right off the bat.
The error usually means that you are using a function or logic with a space between them. Try making your logic call on line two if($_POST['submit']), instead of if ($_POST['submit']) and see if that eliminates the error.
Hope all of this helps!
Jim
-
06-13-2004, 10:56 PM #10Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
Sorry w3needs, I didnt understand anything you said. I tried deleting that one space between if and ($submit) but i received same error.
-
06-13-2004, 11:01 PM #11WHT Addict
- Join Date
- Aug 2003
- Location
- PA
- Posts
- 110
All form fields are transported through pages via normal http calls. But, in order to extract the data in those variables that you used to name the forms, you use the method value to call those variables.
Now, your form was using the method POST to transport the variables in the fields(values in the fields) to the next page. To extract them, so that they can be used throughout your script for whatever purpose you have in mind, you must call them this way:
$_POST['field_name']
not, $field_name
I hope this helps!
Jim
-
06-14-2004, 01:21 AM #12Temporarily Suspended
- Join Date
- Jun 2004
- Location
- India
- Posts
- 71
use .js or php.
have an search in http://www.hotscripts.com
-
06-14-2004, 06:24 AM #13Originally posted by webhoststalk
use .js or php.
-
06-14-2004, 06:56 AM #14WHT Addict
- Join Date
- Jun 2004
- Posts
- 142
Well I think if you use the following php script , Your form will work well.
PHP Code:<?php
//This is the location of your sendmail variable
//if you don't know, contact your sysadmin
$mail_path = "/usr/sbin/sendmail -i -t";
//The email address to be receiving emails from this form
$mail_to = "zan@stargeek.com";
//the subject of the email sent by the form
$mail_subject = "Contact Form";
//the name of the buisness or website that the form contacts
$buisness_name = "Stargeek";
//this is the html of the form used to create the email
$form_html = '$html = "
<h1>
To Contact $buisness_name:
</h1>
<form action=\"$PHP_SELF\" method=\"post\">
<table class=\"mainText\" border=\"0\" cellspacing=\"5\">
<tr>
<td>Your Name: </td>
<td>$name </td>
</tr>
<tr>
<td>Your Email Address:</td>
<td>$reply<td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">Your Message</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$message</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$send</td>
</tr>
</table>
</form>
Script by <a href="http://www.stargeek.com">Stargeek</a>
";';
ini_set("sendmail_from", $mail_from);
ini_set("sendmail_path", $mail_path);
if ($_POST)
{
if($_POST['userEmail'])
{
if( mail($mail_to,$mail_subject,"\t From: ".$_POST['userName']."\n \t Email: ".$_POST['userEmail']. "\n\n\n\n".stripslashes($_POST['userMessage']).'this email was generated by <a href="http://www.stargeek.com">Stargeek</a>\'s script'.,"From: $_POST[userEmail]\r\n"."Reply-To: $_POST[userEmail]\r\n") )
{
$html = 'Thank you for contacting '.$buisness_name.', '.$_POST['userName'].'. <br/>Your email was sent <br/>Script by <a href="htp://www.stargeek.com">Stargeek</a>';
}
else
{
$html = 'There was an error';
}
}
}
else
{
$message = '<textarea name="userMessage" rows="20" cols="70"></textarea>';
$name = '<input type="text" name="userName" size="30">';
$reply = '<input type="text" name="userEmail" size="30">';
$send = '<input type="submit" name="submit" value="Send">';
eval($form_html);
}
?>
<html>
<head>
<title>-{Title Here}-</title>
</head>
<body>
<?=$html?>
</body>
</html><4ulyrics>Cheers ,
Think Lyrics .... Think 4ULYRICS</4ulyrics>
-
06-14-2004, 05:02 PM #15Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
No, it doesn't really matter what script it is. I just dont know what the problem could be. w3needs, I tried the suggestion you said, but same error. Error still at line #2.
-
06-14-2004, 08:27 PM #16WHT Addict
- Join Date
- Aug 2003
- Location
- PA
- Posts
- 110
Do you run any other PHP files on your site? Is PHP 4.0+ installed? Your system is a unix/linux, correct?
Okay, if you answered yes, then there is something else to look at....simply make a file called 'php_test.php' or whatever. Inside, use this code:
PHP Code:<?php
echo phpinfo();
?>
If there is no error, then eliminate the comment in line 2, and see what happens.
You also changed the variable in the logic? Quite possibly, this is another reason for the error.
Please let us know an update on your status, and an update on your code!
I hope it helps!
Jim
-
06-14-2004, 09:19 PM #17Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
Well I made that test:
http://at.th4y.com/php_test.php
Is it all good?
-
06-14-2004, 10:21 PM #18Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
Grr, it didnt let me edit, so I need help.
http://newsourcemedia.com/index_view.php?id=49
That's the script I was using. How would I put that script into this HTML form?
Code:<HTML> <P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0"> <TR> <TD WIDTH="100%" BGCOLOR="black"> <TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2"> <TR> <TD ALIGN="center" COLSPAN="2" BGCOLOR="#F9C304"> <B><FONT COLOR="red" SIZE="-1" FACE="Verdana">Order Page</FONT></B></TD> <FORM METHOD="POST" ACTION="formtomail.asp"> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Name:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="name" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Address:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="address" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">City:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="city" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">State:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="state" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Zip Code:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="zipcode" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Order:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <select name="order"> <option value="doubledragonsword">Double Dragon Sword <option value="ninjablade">Ninja Blade <option value="samurai3000ninja">Samurai 3000 Ninja <option value="samurai3000katana">Samurai 3000 Katana <option value="shogunkatana">Shogun Katana <option value="shogunkatana">Bamboo Katana <option value="ramboknife">Rambo Knife </select> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Payment Method:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <select name="paymentmethod"> <option value="creditcard">Credit Card <option value="check">Check <option value="moneyorder">Money Order <option value="paypal">Paypal </select> </TD> </TR> <TR> <TD WIDTH="48%" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Email:</FONT></B></TD> <TD WIDTH="52%" BGCOLOR="#636563"> <INPUT NAME="email" TYPE="text" SIZE="25"> </TD> </TR> <TR> <TD COLSPAN="2" BGCOLOR="#636563"> <B><FONT COLOR="white" SIZE="2" FACE="Verdana">Comments:<BR> <TEXTAREA NAME="comments" ROWS="5" COLS="45"></TEXTAREA></FONT></B></TD> </TR> <TR> <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563"> <input type="submit" value="Send"> <TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563"> <input type="reset" value="Reset"> </TD> </TR> </FORM> </TABLE></TD> </TR> </TABLE></CENTER></P> </HTML>
-
06-14-2004, 10:30 PM #19<FORM METHOD="POST" ACTION="formtomail.asp">
-
06-14-2004, 10:39 PM #20Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
oops, srry. I was trying some asp script too on different server, but couldn't configure it. I used action="". I didnt put nothing in between "" when I tested the php script, that's how it said it should be on that site as well.
-
06-15-2004, 07:02 AM #21Originally posted by 4ulyrics
Well I think if you use the following php script , Your form will work well.
-
06-15-2004, 11:39 AM #22Web Hosting Master
- Join Date
- Aug 2003
- Location
- St. Louis, Missouri
- Posts
- 1,815
Yea, I had the same error from that script thats why I didnt use it. I used to have a perfect php mail script last september, but I have no idea where I found it. All of the ones I find now give some errors and I cant set them up. Next time Im going to burn that scrpt so I can have it for future, thats if I ever configure this one. lol
-
06-16-2004, 01:41 PM #23Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
Okay -- I think everyone missed this part :
mail("haris3636@hotmail.com","From: $name <$email>", $subject, $msg);
The protoype of the mail() function is
Code:bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])
Also, you have a very, very, wrong way of checking if values are submitted. If someone entered just a blank line, it would consider it set -- which is not what you want. Also, register globals is off by default on PHP installations. You cannot use $from -- you have to use $_POST['from'] (as others suggested).
I recommend you start over -- since I have no idea what your current script looks like. There are a few tutorials that will show you how to send email. I suggest you read those first.
-
06-16-2004, 02:36 PM #24WHT Addict
- Join Date
- Apr 2004
- Location
- Port St Lucie, FL
- Posts
- 117
Here's a self-submitting form, based on yours.. make sure it's named with a .php extension.
Note the import_request_variables call - it's important. Does anyone else use it instead of the _POST method?
PHP Code:<?php
import_request_variables("pg", "p_"); // Import the _POST variables to $p_ variables
if ($p_submit)
{ // if the form was sent do the following
if (!($p_name == '' || $p_address == '' || $p_city == '' || $p_state == '' ||
$p_zipcode == '' || $p_order == '' || $p_paymentmethod == '' || $p_email == '' ||
$p_comments == ''))
{
$subject = "Order";
$msg = "Name: $p_name\n Address: $p_address \n City: $p_city \n ";
$msg .= "State: $p_state \n Zip Code: $p_zipcode\n Order: $p_order\n";
$msg .= "Payment Method: $p_paymentmethod \n Email Address: $p_email\n\n";
$msg .= "Comments: $p_comments\n";
if (mail("haris3636@hotmail.com", $subject, $msg))
{
echo "Message Sent"; // if all went well, display message was sent
}
else
{
echo ("Message Failed");
}
}
else
{
echo "All fields must be filled in!<BR>"; // if not all were filled in, display error message
}
}
else
{
// Display the form
?>
<HTML>
<P><CENTER><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD WIDTH="100%" BGCOLOR="black">
<TABLE WIDTH="394" BORDER="0" CELLSPACING="1" CELLPADDING="2">
<TR>
<TD ALIGN="center" COLSPAN="2" BGCOLOR="#F9C304">
<B><FONT COLOR="red" SIZE="-1" FACE="Verdana">Order Page</FONT></B></TD>
<FORM METHOD="POST">
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Name:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="name" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Address:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="address" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">City:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="city" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">State:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="state" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Zip Code:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="zipcode" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Order:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<select name="order">
<option value="doubledragonsword">Double Dragon Sword
<option value="ninjablade">Ninja Blade
<option value="samurai3000ninja">Samurai 3000 Ninja
<option value="samurai3000katana">Samurai 3000 Katana
<option value="shogunkatana">Shogun Katana
<option value="shogunkatana">Bamboo Katana
<option value="ramboknife">Rambo Knife
</select>
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Payment Method:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<select name="paymentmethod">
<option value="creditcard">Credit Card
<option value="check">Check
<option value="moneyorder">Money Order
<option value="paypal">Paypal
</select>
</TD>
</TR>
<TR>
<TD WIDTH="48%" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Email:</FONT></B></TD>
<TD WIDTH="52%" BGCOLOR="#636563">
<INPUT NAME="email" TYPE="text" SIZE="25">
</TD>
</TR>
<TR>
<TD COLSPAN="2" BGCOLOR="#636563">
<B><FONT COLOR="white" SIZE="2" FACE="Verdana">Comments:<BR>
<TEXTAREA NAME="comments" ROWS="5" COLS="45"></TEXTAREA></FONT></B></TD>
</TR>
<TR>
<TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
<input type="submit" value="Send">
<TD ALIGN="center" WIDTH="50%" BGCOLOR="#636563">
<input type="reset" value="Reset">
</TD>
</TR>
</FORM>
</TABLE></TD>
</TR>
</TABLE></CENTER></P>
</HTML>
<?php
} // end php submission code
?>Paul Embry
Knight Software and Web Design
Paul.Embry@gmail.com
Quality PHP Web Programming for Reasonable Prices