Topic: Agh Forms! The Angst!!!  (Read 2581 times)

0 Members and 1 Guest are viewing this topic.

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Agh Forms! The Angst!!!
« on: May 11, 2005, 01:42:30 am »
Ok. I basically wrote a PHP script to send form data to an email address. (It was a shell, so a bit of it was there... a small bit).

I have it so it will send the data to one email address, but not two. (or more). Help anyone?

Help toasty? :P
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline toasty0

  • Application.Quit();
  • Captain
  • *
  • Posts: 8045
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #1 on: May 11, 2005, 11:30:44 pm »
php is Bonk's baliwick, not mine.

Jerry
MCTS: SQL Server 2005 | MCP: Windows Server 2003 | MCTS: Microsoft Certified Technology Specialist | MCT: Microsoft Certified Trainer | MOS: Microsoft Office Specialist 2003 | VSP: VMware Sales Professional | MCTS: Vista

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Agh Forms! The Angst!!!
« Reply #2 on: May 12, 2005, 10:22:05 am »
Been ages since I used the mail functions...  *nix or Windows server? (ie direct call to *nix sendmail vs use of php's mail functions...)

Last time I used mail in php I borrowed code from phpbb's account activation code as I recall...

Try here for info:

http://www.php.net/manual/en/ref.mail.php
http://www.php.net/manual/en/ref.imap.php
http://www.hotscripts.com/PHP/Scripts_and_Programs/Email_Systems/

Perhaps your troubles might be how you are retrieving the variables posted by the form? (i.e. in php5 use $_POST['variablename'] if the POST method was used by the form...  (where 'variablename' corresponds to the name of the form input field that data is desired from)

here's a little script I started playing with while bored the other day - no mail functions - but may help you with forms submission and posted variables... the script posts to itself...

Code: [Select]
<?php
echo ("<html>");
echo (
"<head>");
echo (
"<title>The Oracle</title>");
echo (
"</head>");
echo (
"<body>");
echo (
"<h1>Thinker</h1>");
echo (
"<hr><br><br>");
echo (
"<form method=POST action=");
echo 
$_SERVER['PHP_SELF'];
echo (
">");
echo (
"Enter a question for the oracle:<br><br>");
echo (
"<input type=text name=question size=100><br><br>");
echo (
"<input type=submit value=Ask! name=ask>");
echo (
"</form>");
echo (
"<hr><br><br>");
if (isset(
$_POST['question'])){
$question=strtolower(trim($_POST['question']));
echo ("Reply:<br><br>");
if($question==""){
echo ("Please enter a question. I'm not a mind reader!");
}
if(substr($question,0,3)=="who"){
echo ("You!");
}
if(substr($question,0,4)=="what"){
echo ("Something!");
}
if(substr($question,0,4)=="when"){
echo ("Sometime!");
}
if(substr($question,0,5)=="where"){
echo ("Somewhere!");
}
if(substr($question,0,3)=="why"){
echo ("Because!");
}
if(substr($question,0,3)=="how"){
if(substr($question,0,8)=="how many"){
echo mt_rand(1,10);
} else {
echo ("Some way!");
}
}
}
echo (
"</body>");
echo (
"</html>");
?>


Notice I do not escape back and forth between php and html but rather have php output all the desired html (improves server performance and simplifies things). (Dynaverse.net scripts need a lot of work in this respect.) Note that you can omit certain quotes useage in html output but can output actual quotations by escaping with a slash... i.e.:  \" ...or a single quote will often do... I've omitted most of them in the html output by the script above but it is best to use proper quotes where needed.


Post your script here (minus passwords etc) if you like and I can take a look at it and see if I have any suggestions.
« Last Edit: May 21, 2005, 09:28:31 am by Bonk »

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #3 on: May 12, 2005, 06:25:46 pm »
Ok its kinda ugly because I "wrote" it myself. heh ill dig it up and post in a few.
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #4 on: May 12, 2005, 06:53:10 pm »
send.php (the PHP program doing that reads the forum and mails it).


<?php 
include("config.inc.php");


$ip $_SERVER['REMOTE_ADDR'] ;
$date $_REQUEST['date'] ;
$name $_REQUEST['fname'] ;
$day $_REQUEST['day'] ;
$month $_REQUEST['month'] ;
$year $_REQUEST['year'] ;
$country $_REQUEST['country'] ;
$state $_REQUEST['state'] ;
$alias $_REQUEST['alias'] ;
$email $_REQUEST['email'] ;
$referrer $_REQUEST['referrer'] ;
$gaming $_REQUEST['gaming'] ;
$reason $_REQUEST['reason'] ;
$fees $_REQUEST['fees'] ;
$rules $_REQUEST['rules'] ;


$message "Hi $sitename,

$name has sent you an application on $date. The message is below including his/her IP address and email address:

ip: 
$ip

name : 
$alias 's Testimony
email : 
$email
subject : 
$alias 's Application
message : Date Submitted - 
$date
	
	
  First Name - 
$name
	
	
  Birthdate - 
$day $month $year
	
	
  Country Residing - 
$country
	
	
  State Residing (If in USA) - 
$state
	
	
  Gaming Alias - 
$alias
	
	
  Email Address - 
$email
	
	
  Referrer - 
$referrer
	
	
  Gaming Experience - 
$gaming
	
	
  
	
	
  Reason for wishing to join - 
$reason
	
	
  Willing to pay fees - 
$fees
	
	
  Willing to follow rules - 
$rules

Thanks,

The administrator

-----------------------
Powered by SkyFlyer Webdesign"
;

if(
$logs == "1") {
$log "$date$ip$name$day$month$year$country$state$alias$email$referrer$gaming$reason$fees$rules\r";

// Open the file and erase the contents
$fp fopen("$logsfile""a");
// Write the data to the file
$log str_replace("\n"""$log);
fwrite($fp$log);
// Close the file
fclose($fp);
}


if(
$banip == "1") {
if(
strstr($banip_list$ip)) {
echo 
"<META http-equiv=\"refresh\" content=\"0; URL=$errorpage\">";
}
}
if(
$banemail == "1") {
if(
strstr($banemail_list$email)) {
echo 
"<META http-equiv=\"refresh\" content=\"0; URL=$errorpage\">";
}
}

if(
$autoresponder == "1") {
$autorespond_headers "From: $sitename($address)";
@
mail($email$autorespondersub$autorespondermess$autorespond_headers);
}

@
mail"$address""$subject""$message""From: $email");


echo 
"<META http-equiv=\"refresh\" content=\"0; URL=$donepage\">";

?>


Config.inc.php (the variables).


<?php 
/*  SkyFlyer's forms                              
*/

//
//  Setup
//

$sitename "clanlessfraggers.com"// Site Name
$address "admin@sky-flyer.org";  // Where to send all emails!
$dir ""// Directory where script is installed. eg Site is
	
	
   
// in /. Script is in /contact and it is included you
	
	
   
// would put /contact/. If you accessed the file in
	
	
   
// the /contact/ folder then you would leave it blank

//
// AutoResponse
//
// WARNING : DON'T WRITE ANY " IF YOU DO PUT A \ BEFORE IT, EG.
// \"Administrator\". THIS WILL SHOW AS "ADMINISTRATOR".
// LEAVE BLANK TO DISABLE.
//

$autoresponder "0"// Status, 0 = off 1 = on
$autorespondersub "Thanks for your mail"// Autoresponder Subject
$autorespondermess "Hi,

Thanks for your application you sent to us.
We have recieved the application and will review its content
as soon as possible,

Regards,

Site Administrators"
// Autoresponder Email

//
// Logs
//

$logs "1"// Create Logs, 0 = off 1 = on
$logsfile "logs.txt";

//
// Banned
//

$banip "1"// Ban IP's, 0 = off 1 = on
$banip_list "111.222.33.44,555,666,77,88"// Banned IP's, seperate by comma
$banemail "1"// Ban Emails, 0 = off 1 = on
$banemail_list "test@test.com,test2@test2.com"// Banned Emails, seperate by comma

//
// Field Limits
//
// WARNING : ONLY ENTER NUMBERS IN THE ", NOTHING ELSE!
//
//
// Error/Done Pages
//

$donepage "done.html"// Thank You/Done page
$errorpage "error.html"// Banned IP/Email Page.

?>
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #5 on: May 12, 2005, 06:54:08 pm »
Ohh Nice the PHP tags work. Did that come with SMF or is that a mod, bonk? If its a mod can you send it to me?
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #6 on: May 19, 2005, 02:11:07 am »
Resolved :)
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Agh Forms! The Angst!!!
« Reply #7 on: May 20, 2005, 11:46:12 am »
glad you worked it out...  :)  (I'm not on the boards much at the moment, sorry)

Not sure about the PHP code tags here, I seem to remember something about it... a setting somewhere... I'll see if I can find it when I get the chance.

Offline SkyFlyer

  • D.Net Beta Tester
  • Commander
  • *
  • Posts: 4240
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #8 on: May 21, 2005, 04:06:45 am »
Yeah it turned out one of the very first things I tried actually worked... just my spam blocker caught it.
Life is short... running makes it seem longer.

"A god who let us prove his existence would be an idol" - Dietrich Bonhoeffer

Offline Bonk

  • Commodore
  • *
  • Posts: 13298
  • You don't have to live like a refugee.
Re: Agh Forms! The Angst!!!
« Reply #9 on: May 21, 2005, 09:25:57 am »
Quote
Ohh Nice the PHP tags work. Did that come with SMF or is that a mod, bonk? If its a mod can you send it to me?


...seems its been built into SMF for a while now:  8)
http://www.simplemachines.org/community/index.php?topic=1621.0

testing:


<?php
echo "Hello!";
?>


Code: [Select]
<?php
echo "Hello!";
?>


it seems it likes to see the   <?php code here; ?>    php syntax to work properly, if you leave the leading <?php tag out it doesent work right inside a code tag.

Offline toasty0

  • Application.Quit();
  • Captain
  • *
  • Posts: 8045
  • Gender: Male
Re: Agh Forms! The Angst!!!
« Reply #10 on: May 21, 2005, 10:09:41 am »
This is a test: Please ignore the contents of this post.


private void Page_Load(object senderSystem.EventArgs e)
	
	
{
	
	
	
// Put user code to initialize the page here
	
	
	
Response.Write("Testing the RandomNumber Component<hr>");
	
	
	
//Display the properties of the component
	
	
	
Response.Output.Write("MinValue: {0}, "+
	
	
	
	
"MaxValue: {1}",
	
	
	
	
randomNumber1.MinValue,
	
	
	
	
randomNumber1.MaxValue);
	
	
	
Response.Write("<br>");
	
	
	
//Call the method fo the component
	
	
	
Response.Output.Write("Generate Random "+
	
	
	
	
"Number: {0}",
	
	
	
	
randomNumber1.GenerateRandomNumber());
	
	
}



Hmmm...interesting.

Jerry
MCTS: SQL Server 2005 | MCP: Windows Server 2003 | MCTS: Microsoft Certified Technology Specialist | MCT: Microsoft Certified Trainer | MOS: Microsoft Office Specialist 2003 | VSP: VMware Sales Professional | MCTS: Vista