hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Email form?
Reply

Forum Jump

Email form?

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-13-2004, 05:45 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814

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?



Sponsored Links
  #2  
Old 06-13-2004, 06:17 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: Mayberry
Posts: 19,703
Not enough info to help with a script.
What script?
What happens?
Any errors?
That sort of thing.

  #3  
Old 06-13-2004, 06:36 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814
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
?>
Is that right? Any errors? I put that above the start of the FORM.

Sponsored Links
  #4  
Old 06-13-2004, 07:02 PM
Barti1987 Barti1987 is offline
Web Hosting Master
 
Join Date: Mar 2004
Location: USA
Posts: 4,342
Download free sample forms:
Contact Form-- Free PHP Scripts

__________________
Testing 1.. Testing 1..2.. Testing 1..2..3...

  #5  
Old 06-13-2004, 07:05 PM
Barti1987 Barti1987 is offline
Web Hosting Master
 
Join Date: Mar 2004
Location: USA
Posts: 4,342
it also has a nice tutorial to apply

peace,

__________________
Testing 1.. Testing 1..2.. Testing 1..2..3...

  #6  
Old 06-13-2004, 07:09 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814
That form has big code, it'll take too long to edit.

  #7  
Old 06-13-2004, 07:43 PM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: Mayberry
Posts: 19,703
Quote:
Originally 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
?>
Is that right? Any errors? I put that above the start of the FORM.
OKay, your form first.
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?

  #8  
Old 06-13-2004, 09:31 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814
ok, I've made seperate html and php files. But when I fill out the form and click submit, this message comes.

Quote:
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
This is whole php code in sendmail.php starting with line 1:

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
?>
Click here to go directly to that page

  #9  
Old 06-13-2004, 10:17 PM
w3needs w3needs is offline
WHT 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

  #10  
Old 06-13-2004, 10:56 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814
Sorry w3needs, I didnt understand anything you said. I tried deleting that one space between if and ($submit) but i received same error.

  #11  
Old 06-13-2004, 11:01 PM
w3needs w3needs is offline
WHT 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

  #12  
Old 06-14-2004, 01:21 AM
webhoststalk webhoststalk is offline
Temporarily Suspended
 
Join Date: Jun 2004
Location: India
Posts: 71
use .js or php.

have an search in http://www.hotscripts.com

  #13  
Old 06-14-2004, 06:24 AM
bear bear is online now
Community Leader
 
Join Date: Oct 2002
Location: Mayberry
Posts: 19,703
Quote:
Originally posted by webhoststalk
use .js or php.
^^ that is PHP. ^^

  #14  
Old 06-14-2004, 06:56 AM
4ulyrics 4ulyrics is offline
WHT 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>
You can get more information about this script by visiting http://www.stargeek.com/php_scripts.php?script=12

__________________
<4ulyrics>Cheers ,
Think Lyrics .... Think 4ULYRICS</4ulyrics>

  #15  
Old 06-14-2004, 05:02 PM
WHTer WHTer is offline
Web Hosting Master
 
Join Date: Aug 2003
Location: St. Louis, Missouri
Posts: 1,814
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.

Reply

Related posts from TheWhir.com
Title Type Date Posted
Introducing .HOST: The Exciting New gTLD for the Global Hosting Community Webinars 2014-09-11 13:44:36
Security Experts Refute German Email Security Firms Secure Data Storage Claim Web Hosting News 2013-08-13 16:24:48
Cloudmark Shares Strategies to Avoid Email Blacklisting, Improve Deliverability Blog 2013-05-31 14:57:24
Super Charge Your Trial Program Blog 2013-05-16 09:48:11
Lead Generation Part 1 – Form Fills Blog 2012-11-16 09:03:48


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?