Jump to content

PHP Form Submission


jrapin

Recommended Posts

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


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

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

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 $email
echo "<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

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 32

Does 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

[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

[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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.