Forms

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
Yes, that's what cgieemail does. By the way, that apply form doesn't send an email. Well it might, but its main purpose is to create a post in the Apply for Hosting forum.

When I said that I didn't know exactly what you want, I was referring to the actual HTML form and how it appeared, not how it emailed you. cgieemail is already installed in cPanel (well, it's like already installed on your website as a CGI script) so just follow the steps where I told you to and you got it.

It doesn't really matter, but it's located in \public_html\cgi-bin\.
 

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
ok here we go... with me here? :grin:

ok, start making the contact.php page... this has the form...

contact.php
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>

<form method="post" action="sendmail.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Subject: <br />
<input type="text" name="sub" size="35" />
<br />
Your Name:<br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
</form>

</body>
</html>

and then make the sendmail.php which will send the mail

sendmail.php
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Mail Sent</title>
</head>
<body>

<!-- Required: YOUR email ($myemail). Optional: Enter CC email address ($ccx) 
Required: Add the link for the 'next page' (at the bottom) --> 

<?php
$myemail = "your@email"; 
$ccx = ""; 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a") ;

$subject = $sub; 

$notes = stripcslashes($notes); 

$message = " $todayis [EST] \n
Message: $notes \n 
From: $visitor ($visitormail)\n
Additional Info: IP = $ip \n
Browser Info: $httpagent \n
Referral: $httpref \n
";

$from = "From: $visitormail\r\n";

if (($ccopy == "ccyes") && ($visitormail != "")) 
mail($visitormail, $subject, $message, $from);

if ($myemail != "") 
mail($myemail, $subject, $message, $from);

if ($ccx != "") 
mail($ccx, $subject, $message, $from);

?>

<p align="left">
Subject:: <?php echo $subject ?>
Date: <?php echo $todayis ?> 
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br />
<?php echo $ip ?> 

<br /><br />
<a href="contact.php"> Back to Contact</a> 
</p> 

</body>
</html>

If you need superglobals then put this in sendmail.php

Code:
<?php
$ip = $_POST['ip']; 
$httpref = $_POST['httpref']; 
$httpagent = $_POST['httpagent']; 
$visitor = $_POST['visitor']; 
$visitormail = $_POST['visitormail']; 
$notes = $_POST['notes'];
?>

you can easily implament this into your normal site by taking out the html at the beginning and end then placing it into a table or something, depending on what your site layout is using.

hope this helps :eek:nline2lo
 
Last edited:

Skyline4life

New Member
Messages
894
Reaction score
0
Points
0
ok its sending me the E-mail, but im getting this

Use Back - fill in all fields they all are..

and in the E-mail i get this

Tuesday, June 7, 2005, 11:50 am [EST]

Message:

From: ()

Additional Info : IP = MyIp

Browser Info: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Referral :

I am using darkd45 code
 

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
hmm let me look at it for a minute, i havn't tried it on my server yet... i think i messed up in a part lol

lol, i think i got what is wrong... i was at school and can not test the scripts lol :innocent:
 

Jake

Developer
Contributors
Messages
4,057
Reaction score
5
Points
0
OK... Ready for this?? :laughing:
I foudn out my mistakes with the coding and i am not sure what you put into the boxes wehen testing the script but i do know that it worked when i tried it out after i fixed the script...

I put in
Code:
Subject: Php Script
Your Name: DarkD45
Your E-Mail: midwestphython@hotmail.com
Mail Message:
Hello
Spaces ok...
Sizes ok...

then after that i got this in an e-mail labeled from "midwestphython" (i use gmail btw, darkd45@gmail.com) and it said this...

Code:
 Tuesday, June 7, 2005, 4:10 pm [EST]


Subject: Php Script

From: DarkD45

E-mail: midwestphython@hotmail.com


Message:

Hello
Spaces ok...
size ok...



Additional Info:

IP: ------------------- (worked, but i am not showing =P)

Browser Info: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Referral: http://www.outpost4.com/testscript/sendmail.php


The new script is bellow and i tested it and it works to my knowledge... so try this one...

contact.php
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Email Form </title>
</head>
<body>

<form method="post" action="sendmail.php">

<!-- DO NOT change ANY of the php sections -->
<?php
$ipi = getenv ("REMOTE_ADDR");
$httprefi = getenv ("HTTP_REFERER");
$httpagenti = getenv ("HTTP_USER_AGENT");
?>

<input type="hidden" name="ip" value="<?php echo $ipi ?>" />
<input type="hidden" name="httpref" value="<?php echo $httprefi ?>" />
<input type="hidden" name="httpagent" value="<?php echo $httpagenti ?>" />


Subject: <br />
<input type="text" name="sub" size="35" />
<br />
Your Name:<br />
<input type="text" name="visitor" size="35" />
<br />
Your Email:<br />
<input type="text" name="visitormail" size="35" />
<br /> <br />
Mail Message:
<br />
<textarea name="notes" rows="4" cols="40"></textarea>
<br />
<input type="submit" value="Send Mail" />
</form>

</body>
</html>

and then

sendmail.php
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Mail Sent</title>
</head>
<body>

<!-- Required: YOUR email ($myemail). Optional: Enter CC email address ($ccx) 
Required: Add the link for the 'next page' (at the bottom) --> 

<?php
$myemail="You@name"; 
$ccx = ""; 
if(!$visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,"."))) 
{
echo "<h2>Use Back - Enter valid e-mail</h2>\n"; 
$badinput = "<h2>Feedback was NOT submitted</h2>\n";
}
if(empty($visitor) || empty($visitormail) || empty($notes )) {
echo "<h2>Use Back - fill in all fields</h2>\n";
}
echo $badinput;

$todayis = date("l, F j, Y, g:i a");
$subject = $sub;
$notes = stripcslashes($notes); 
$message = " $todayis [EST] \n

Subject: $subject \n
From: $visitor \n
E-mail: $visitormail\n\n
Message:\n
$notes \n\n\n
Additional Info: \n
IP: $ip \n
Browser Info: $httpagent \n
Referral: $httpref \n
";

$from = "From: $visitormail\r\n";

if (($ccopy == "ccyes") && ($visitormail != "")) 
mail($visitormail, $subject, $message, $from);

if ($myemail != "") 
mail($myemail, $subject, $message, $from);

if ($ccx != "") 
mail($ccx, $subject, $message, $from);

?>

<p align="left">
Subject: <?php echo $subject ?>
<br />
Date: <?php echo $todayis ?>
<br />
Thank You : <?php echo $visitor ?> ( <?php echo $visitormail ?> ) 
<br /> 
Message:<br /> 
<?php $notesout = str_replace("\r", "<br/>", $notes); 
echo $notesout; ?> 
<br />
Your IP:
<br />
<?php echo $ip ?> 

<br /><br />
<a href="contact.php"> Back to Contact</a> 
</p> 

</body>
</html>

THIS should work and if it doesn't i would not know why because i tested this a few times just a few minutes ago and everything worked properly... :happy:

- DarkD45
 

Chris

New Member
Messages
1,538
Reaction score
0
Points
0
MicrotechXP said:
WHy are we off topic?

Uhh, what are you talking about?

darkd45 is assisting Skyline4life on creating a form that emails you the form data through PHP.
 

-FK69-

New Member
Messages
12
Reaction score
0
Points
0
What name does the email template have to be for the cgiemail to work cos all i get when i do this:

How do I tell if the installation worked?
Try opening the URL for where you've installed cgiemail, e.g.

http://www.myname.com/cgi-bin/cgiemail/

i get this:

Error
No email was sent due to an error.

500 Empty template file

/home/sgfx/public_html/

cgiemail 1.6

my email template is uploaded in cgi-bin as email.txt
 

rlodge

Member
Messages
230
Reaction score
0
Points
16
Well I'm happy (and amazed). I got the cgiemail to work first try with a Cc of the e-mail sent to my boss upon the user submitting the form. The hardest part I had was trying to install cgiemail and finding out it was already in my cgi-bin folder.

I know, this is no great deal to most of you but it's a giant leap for me!
 
Top