jrapin Posted November 14, 2006 Share Posted November 14, 2006 Local PHP Members,I'm considering employing a technique (using the POST method) to submit a fillable form either in the form of a e-mail or to a database. I really want to stay as simple as possible - becuase I'm not a programmer but rather a multimedia designer.Does anyone know a php script that would allow users to submit a form to my website thru an e-mail post technique? Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/ Share on other sites More sharing options...
blear Posted November 14, 2006 Share Posted November 14, 2006 This is an extremely broad question. The only answer I can give is to look at the documentation. There are nearly limitless ways to do this.You might consider first asking yourself, what do you want out of the site? How much traffic? What size and type of data will users submit? Who will be my users? Can I trust my users? How many users? Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124487 Share on other sites More sharing options...
jrapin Posted November 14, 2006 Author Share Posted November 14, 2006 Yes - The user can be trusted because they are not submitting CC info or anything like that.the form would receive moderate traffic but I really want a technique that will simply send the form fields to an e-mai address.This form serves as a reservation for a convention. It needs to be filled out and e-mailed to a specific address. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124534 Share on other sites More sharing options...
Bri Posted November 14, 2006 Share Posted November 14, 2006 This is a quick post but here you go:Index.php[code]<html><head><title>Mail sender</title></head><body><form action="emailbackend.php" method="POST"><p><b>Subject</b><br /><input type="text" name="subject" size=40><p><b>Message</b><br /><textarea cols=40 rows=10 name="message"></textarea><p><input type="submit" value=" Send "></form></body></html> [/code]emailbackend.php[code]<html><head><title>PHP Mail Sender</title></head><body><?php$email = 'YOUR EMAIL ADDRESS HERE';$subject = $HTTP_POST_VARS['subject'];$message = $HTTP_POST_VARS['message'];if ($subject == "") {echo "<h4>No subject</h4>";echo "<a href='javascript:history.back(1);'>Back</a>";} else {if ($message == "") {echo "<h4>No message</h4>";echo "<a href='javascript:history.back(1);'>Back</a>";elseif (mail($email,$subject,$message)) {echo "<h4>Thank you for your email, I will reply asap</h4>";echo "<a href='javascript:history.back(1);'>Back</a>";} else {echo "<h4>Can't send email</h4>"; //to $emailecho "<a href='javascript:history.back(1);'>Back</a>";}?></body></html>[/code]or something like that, not checked the code but it might help.Bri Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124614 Share on other sites More sharing options...
jrapin Posted November 14, 2006 Author Share Posted November 14, 2006 Thak you sir, I'll try it immediately. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124666 Share on other sites More sharing options...
jrapin Posted November 14, 2006 Author Share Posted November 14, 2006 I tried this PHP code to find there was an error before the elseif (mail ($email, $subject, $message)) {.Deceided to insert the } before the mail. Worked but then, received this error:Parse error: parse error, unexpected $end in c:\Inetpub\wwwroot\PHP_practice\emailconventions.php on line 32Does anyone know what is causing this error message. Why is there an enexpected $end on line 32? Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124693 Share on other sites More sharing options...
jrapin Posted November 14, 2006 Author Share Posted November 14, 2006 The parse error -tells me that there is a syntactical mistake in the code.The error is in the emailbackend.php file right on line 21 (elseif (mail ($email, $subject, $message)) {Could some one enlighten me as to what the solution to the problem is? Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124700 Share on other sites More sharing options...
fert Posted November 15, 2006 Share Posted November 15, 2006 there's no } before elseif Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124768 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 I've removed the { before elseif and the code and I still get the error message.Please help... Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124958 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 [code]<html><head><title>PHP Mail Sender</title></head><body><?php$email = 'YOUR EMAIL ADDRESS HERE';$subject = $HTTP_POST_VARS['subject'];$message = $HTTP_POST_VARS['message'];if ($subject == ""){ echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>";}else{ if ($message == "") { echo "<h4>No message</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for your email, I will reply asap</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } else { echo "<h4>Can't send email</h4>"; //to $email echo "<a href='javascript:history.back(1);'>Back</a>"; }}?></body></html>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124964 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 Now I get this:Notice: Undefined variable: HTTP_POST_VARS in c:\Inetpub\wwwroot\emailbackend.php on line 6Notice: Undefined variable: HTTP_POST_VARS in c:\Inetpub\wwwroot\emailbackend.php on line 7No subject Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124968 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 Change-$subject = $HTTP_POST_VARS['subject'];$message = $HTTP_POST_VARS['message'];To-$subject = $_POST['subject'];$message = $_POST['message'];Orio. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124969 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 What about the e-mail address on line 5?When using this: $email = $_POST['email'] = '[email protected]';I receive this message:Parse error: parse error, unexpected '}' in c:\Inetpub\wwwroot\emailbackend.php on line 5 Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124971 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 [code]<html><head><title>PHP Mail Sender</title></head><body><?php$email = '[email protected]'; //enter your real email address to this vairable$subject = $_POST['subject'];$message = $_POST['message'];if ($subject == ""){ echo "<h4>No subject</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>";}else{ if ($message == "") { echo "<h4>No message</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } elseif (mail($email,$subject,$message)) { echo "<h4>Thank you for your email, I will reply asap</h4>"; echo "<a href='javascript:history.back(1);'>Back</a>"; } else { echo "<h4>Can't send email</h4>"; //to $email echo "<a href='javascript:history.back(1);'>Back</a>"; }}?></body></html>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124975 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 Thanks for the help. I'm not a programmer.Using the code you provided for me, I get this message:Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in c:\Inetpub\wwwroot\emailbackend.php on line 23Can't send email Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124977 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 Try entering (after the opening <?php) the following line-ini_set("sendmail_from", NULL);Orio. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-124979 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 Orio,Placed the code in the first line of PHP, got this message:Warning: mail() [function.mail]: SMTP server response: 550 5.7.1 Unable to relay for [email protected] in c:\Inetpub\wwwroot\emailbackend.php on line 23Can't send email Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-125006 Share on other sites More sharing options...
Orio Posted November 15, 2006 Share Posted November 15, 2006 Are you sure that all of the mail's configuration is ok?Orio. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-125039 Share on other sites More sharing options...
jrapin Posted November 15, 2006 Author Share Posted November 15, 2006 Yes- I this is valid code and thank you very much for the help!Have a good day. Link to comment https://forums.phpfreaks.com/topic/27228-php-form-submission/#findComment-125055 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.