Current location: Hot Scripts Forums » Programming Languages » PHP » AO FormMail Urgent Question


AO FormMail Urgent Question

Reply
  #1 (permalink)  
Old 01-26-10, 02:59 PM
MacMonster MacMonster is offline
New Member
 
Join Date: Jan 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation AO FormMail Urgent Question

Hi All,

I recently downloaded AO FormMail from this site and despite my best efforts am completely lost in getting it to work with my form.

I have named all my form elements to match those of the demo form on the AO Mail website other than the fact that I do not have a subject field (ok as is overwritten by a subject setting in the script) but I have an extra "website" element that I want to include in the email that gets sent by the script.

Below is the code for my form and the default code for the AO Mail script, please can someone point out what I need to do to include my "website" field in the script?

Any help is greatly appreciated as this is very time sensitive

Code:
<form action="formmail.php" method="get" accept-charset="utf-8">
	<fieldset>
		<legend>Contact The Studio</legend>
		<p>
		<label for="name">Name</label><br />
		<input type="text" name="name" value="" id="name">
		</p>
		<p>
		<label for="email">Email</label><br />
		<input type="text" name="email" value="" id="email">
		</p>
		<p>
		<label for="website">Website</label><br />
		<input type="text" name="website" value="" id="website">
		</p>
		<p>
		<label for="comment">Comment</label><br />
		<textarea cols="30" rows="10" name="message" id="message"></textarea>
		</p>
	</fieldset>
	<p><input name="submit" type="submit" id="submit" value="Submit"></p>
</form>
Code:
<?php
/* ******************************** */
/*     Azabia Business Services	    */
/*         www.azabia.co.uk	    */
/* 	 AO - FormMail Script	    */
/*				    */
/*  Release Date: 	26/03/2008  */
/*  Revision Date:	14/04/2008  */
/*  Version:		1.01	    */
/* ******************************** */
/*  Modify these settings below...  */
/* ******************************** */

// Set any required fields below. Separate each one with a comma.
$required_fields		="field1,field2,field3";
								
// Set the URL where you want the user to be redirected to if the submission is successful.
// This can be overridden by having a hidden form field as 'success_url'
$success_url			="http://www.mywebsite.co.uk/success.php";

// Set the URL where you want the user to be redirected to if the submission failed.
// This can be overridden by having a hidden form field as 'failed_url'
$failed_url			="http://www.mywebsite.co.uk/failed.php";

// Set this to 0 to disable sending emails (e.g. you only want to enter it in a database)
$send_email			=1;

// Set the email addresses you want the script to email to.
// Assign each email address a number, and in the form make a field called "email_to" and the value being the number.
// If no number is specified, then it will email all the addresses on the list.
$email_to			=array(	"1"		=>"myemail@mywebsite.co.uk",
					"2"		=>"sales@mywebsite.co.uk");
								
// If you want to email just one address, comment out the above array and uncomment this one, then specify the email address.
//$email_to			="sales@mywebsite.co.uk";

// Check referrer? Set to 1 to enable (recommended) and specify allowed pages below. Set to 0 to disable.
$check_referrer			=1;

// Here you can enter a list of referrers (webpages) that can use your script. You can also turn each one on/off too.
// 1 = on (allowed), 2 = off
$referrer_ok			=array(	"http://www.mywebsite.co.uk/contactus.php"			=>1,
					"http://mywebsite.co.uk/contactus.php"				=>1,
					"http://www.matessite.co.uk/spammer.php"			=>0);
							
// Here are the database settings, set the following value to 1 if you want to input the stored data into the database.
// See the documentation at http://www.azabia.co.uk/phpscripts/ao_formmail.php for information on how this works.
$store_db			=0;

// List the form fields (separate by a comma) that you do not want to enter in to the database.
$exclude_fields			="submit,email_to,success_url,failed_url,subject";

$db_username			="";			// Username for the database
$db_password			="";			// Password for the database
$db_database			="";			// Database name
$db_hostname			="localhost";		// Hostname to connect to the database (usually localhost)
$table_name			="";			// Name of the table to insert into

// This will form the beginning of the email that is sent (remember to end it in \r\n)
$message			="Here is the result of a form submitted through ".$_SERVER['HTTP_REFERER']."\r\n\r\n";

// This will be the subject of the email that is sent, can be overridden by adding a form field 'subject'.
$subject			="Form Submission Result";

// The name which will appear in the From: field when the email is sent to you (handy for allowing mail)
$from_name			="AO FormMail";

// The email address which will appear in the From: field when the email is sent to you
$email_From			="formmail@mywebsite.co.uk";

/* ******************************** */
/*	Stop modifying now...	    */
/* ******************************** */

function safe_q($value) {
 if(get_magic_quotes_gpc()) { $value=stripslashes($value); }
 if(function_exists("mysql_real_escape_string")) { $value=mysql_real_escape_string($value); }
 else { $value=addslashes($value); }
 return $value;
}

$err=0;

if($check_referrer) {
 if($referrer_ok[$_SERVER['HTTP_REFERER']]) {
  $allowed=1;
 }
 else {
  $allowed=0;
 }
}
else {
 $allowed=1;
}

if($allowed) {
 if($store_db) {
  $efields=explode(',',$exclude_fields);
  foreach($efields as $a) {
   unset($_REQUEST[$a]);
  }
  $link=mysql_connect($db_hostname, $db_username, $db_password) or die("Unable to connect to Database");
  mysql_select_db($db_database,$link) or die("Unable to connect to Database");
  $sql="INSERT INTO ".$table_name." (";
  $sql2=") VALUES(";
  $sql_end=")";
 }

 $cfields=explode(',',$required_fields);
 foreach($cfields as $a) {
  if(!$_REQUEST[$a]) { $err++; }
 }
 $x=0;
 foreach($_REQUEST as $a => $b) {
  $message.=$a.": ".$b."\r\n";
  if($store_db) {
   if($x>=1) {
    $sql.=", ";
    $sql2.=", ";
   }
   $sql.="`".$a."`";
   $sql2.="'".$b."'";
  }
  $x++;
 }
 if($store_db) {
  $query=$sql.$sql2.$sql_end;
 }
 if($err) {
  if($_REQUEST['failed_url']) {
   Header('Location: '.$_REQUEST['failed_url']);
  }
  elseif($failed_url) {
   Header('Location: '.$failed_url);
  }
  else {
  ?>
  <p align="center"><strong>Your form submission contained errors, please press the back button and try again.</strong></p>
  <?php
  }
 }
 else {
  if($_REQUEST['subject']) {
   $subject=$_REQUEST['subject'];
  }
  if(is_array($email_to)) {
   if($_REQUEST['email_to']) {
    if($send_email) {
     $email_to=$email_to[$_REQUEST['email_to']];
     mail($email_to,$subject,$message,"From: ".$from_name." <".$email_from.">");
    }
   }
   else {
    foreach($email_to as $a => $b) {
     if($send_email) {
      mail($b,$subject,$message,"From: ".$from_name." <".$email_from.">");
     }
    }
   }
  }
  else {
   if($send_email) {
    mail($email_to,$subject,$message,"From: ".$from_name." <".$email_from.">");
   }
  }
  if($store_db) {
   mysql_query($query) or die("Error adding data to database. Check the table structure.");
   mysql_close($link);
  }
  if($_REQUEST['success_url']) {
   Header('Location: '.$_REQUEST['success_url']);
  }
  elseif($success_url) {
   Header('Location: '.$success_url);
  }
  else {
  ?>
  <p align="center"><strong>Thank you for your form submission.</strong></p>
  <?php
  }
 }
}
else {
?>
<p align="center"><strong>Sorry, the referrer is invalid.</strong></p>
<?php
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-26-10, 04:24 PM
carters-site's Avatar
carters-site carters-site is offline
Wannabe Coder
 
Join Date: Sep 2009
Location: Moline, IL
Posts: 100
Thanks: 2
Thanked 1 Time in 1 Post
Are you just wanting them to fill out a form that sends you an email?

If so, I think you might using a little more firepower then necessary here.
You could use a small amount of php code to have an email sent from a form.

I do not have time right now to write the code to do it but if this is all you are wanting to do I am sure someone on here will whip you a quick solution or link to one.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-26-10, 08:01 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Delete your email stuff, and post your code, because the script works on my server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Injecting a string into an If Statement ? nova912 PHP 4 07-21-06 03:04 PM
solve this question to me please urgent dina Flash & ActionScript 3 06-02-06 09:16 PM
URGENT help needed $$$ - Formmail script avalon Job Offers & Assistance 0 05-22-05 09:16 PM
Formmail question sixflagsga PHP 1 12-28-04 02:32 PM


All times are GMT -5. The time now is 02:47 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.