Post to third party after submit

<?php

//Post Form
function post_form($entry,$form){
$post_url = 'http://mydomain.com/mypage';
$body = array(
'firstName' => $entry[1],
'lastName' => $entry[2],
'email' => $entry[3]
);
send_form($post_url,$body);
}

//Send Form
function send_form($post_url,$body){
$request = new WP_Http();
$response = $request->post($post_url, array('body' => $body));
}

//Form Actions
add_action('gform_after_submission', 'post_form', 10, 2);

?>

Disable form submit on enter

<form action="sent.asp" method="post" onkeypress="return disableEnterKey(event);">

<script language="JavaScript">
function disableEnterKey(e)
{
var key;

if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox

if(key == 13)
return false;
else
return true;
}
</script>

CDO SendMail Script

<%
email = "[email protected]"
'check for email address...
if (email <> "") then 'need an email addy

Set Mail = Server.CreateObject("CDO.Message")

Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mydomain.com" 'SMTP link to your server
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = ***Port ID*** 'SMTP Port
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 'Use SSL for the connection
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" 'email account actually sent from
Mail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password" 'password for email account from above

Mail.Configuration.Fields.Update

Mail.From = "[email protected]" 'email you want it to be sent from

Mail.To = "[email protected]" 'email you want it sent to

Mail.HTMLBody = "Body Content Goes Here" 'content ofemail

Mail.Subject = "Subject" 'subject of email

On Error Resume Next
Mail.Send

if Err <> 0 Then
Response.Write "<font color=red size=+1>An error occurred while sending the email....</font>"
response.write(Err.Description)
else
response.write("Thank you.") 'Thank you for sending email
end if 'error
else
response.write("No Email submitted. Please try again") 'Need email to send to to process
end if 'need an email

%>

Select dropdown value

<script type="text/javascript">

var w = document.tvltNewPost.tvltNewCategory.selectedIndex;
var selected_text = document.tvltNewPost.tvltNewCategory.options[w].text;
alert(selected_text);

</script>

Array of select options

<?php

if(isset($_POST['submit'])){
$selected_ratio = $_POST['selected_ratio'];
$ratio_array = explode(',', $selected_ratio);

$the_width = $ratio_array[0];
$the_height = $ratio_array[1];
$the_name = $ratio_array[2];
$aspect_ratio = $ratio_array[3];
}

?>

<form action="" method="post">
<select class="select_field" name="selected_ratio">
<option value="1280,720,HD 720,16:9" <?php if($selected_ratio == '1280,720,HD 720,16:9') echo 'selected="selected"';?>>HD 720</option>
<option value="1920,1080,HD 1080,16:9" <?php if($selected_ratio == '1920,1080,HD 1080,16:9') echo 'selected="selected"';?>>HD 1080</option>
</select>
<input class="calculate_btn" name="" type="submit" value="Calculate Ratio" />
</form>

HypAjaxObject

<?php
class HypAjaxObject{
private static $instance;
private static $version;
private $_version;
private $_div_id;
private $_div_class = 'hyp-ajax-object';
private $_file_urls = array();

private function __construct($div_id,$here){
$this->_div_id = $div_id;
$this->_version = self::$version;
$this->check_post_data();
if($here) $this->drop_target();
}
public static function create($div_id,$here = false){
if(!isset(self::$instance)){
self::print_javascript();
self::$version = 1;
self::$instance = new HypAjaxObject($div_id,$here);
}
else{
self::$version += 1;
self::$instance = new HypAjaxObject($div_id,$here);
}
return self::$instance;
}

//Public Functions
public function get_file($url){
array_unshift($this->_file_urls,$url);
echo "javascript:hypAjaxLoad('$this->_div_id','$url');";
}
public function get_urls(){
return $this->_file_urls;
}
public function get_version(){
return $this->_version;
}
public function get_data(){
$form_name = $_POST['hyp_ajax_data'];
return $_SESSION['hyp_ajax'][$form_name];
}
public function close_link(){
echo "javascript:document.getElementById('$this->_div_id').innerHTML = '';";
}
public function drop_target(){
?>
<div id="<?php echo $this->_div_id ?>" class="<?php echo $this->_div_class ?>"></div>
<?php
}

//Private Class Functions
private function check_post_data(){
if(isset($_POST['hyp_ajax_data'])){
$form_name = $_POST['hyp_ajax_data'];
if($_POST == $_SESSION['hyp_ajax'][$form_name]['post']) return;
$_SESSION['hyp_ajax'][$form_name]['post'] = $_POST;
$_SESSION['hyp_ajax'][$form_name]['get'] = $_GET;
}
if(isset($_POST['hyp_ajax_url'])){
?>
<script type="text/javascript">hypAjaxLoad('<?php echo $this->_div_id ?>','<?php echo $_POST['hyp_ajax_url'] ?>');</script>
<?php
}
$this->check_form_reset();
}
private function check_form_reset(){
$div_id = $this->_div_id;
$form_name = $_POST['hyp_ajax_data'];
if(isset($_POST['reset'])){
unset($_SESSION['hyp_ajax'][$form_name]);
}
}
private function print_javascript(){
?>
<script type="text/javascript">
var currentUrl;

function hypAjaxLoad(target,url){
if(currentUrl == url){
document.getElementById(target).innerHTML = '';
currentUrl = '';
return;
}
else currentUrl = url;

if(window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");//For Ie5+Ie6

xmlhttp.onreadystatechange = function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200) document.getElementById(target).innerHTML = xmlhttp.responseText;
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
<?php
}
}

/*
HypAjaxObject
Built using a Polyton Design Pattern
By Adam J Nowak ~ http://hyperspatial.com

An Ajax loader for PHP programmers. This class allows you to harness the power of Javascript's XMLHttpRequest capability, without having to write a single line of Javascript code.

Public Methods:

create();
Constructor method. Second argument of true creates the div which will contain the loaded file immediately on instantiation. Pass true only if you want your trigger above the loaded ajax content
Ex1: $ajax_object = HypAjaxObject::create('main-ajax-target',true);

get_version();
Instance version number,
Ex2: $ajax_object->get_version();

get_file();
Location of the file to load dynamically. Place this call within a link href or a javascript onlclick attribute. Loading php files with this methos is especially powerful.
Ex3: <a href="<?php $ajax_object->get_file('myfile.php') ?>">Load Content</a>
Ex4: <span onclick="<?php $ajax_object->get_file('myfile.php');">Load Content</span>

get_urls();
Returns an array of the current urls of the files to be loaded with ajax for the object.

get_data();
Returns an array of the data posted by the form for the object

close_link();
Call this within an a href or an onclick attribute in order to create a "Close Ajax Div" button.

drop_target();
Drop target creates the div which will contain the loaded file. The target will automatically have the css id and class based on the constructor, create(); If you want your trigger above the loaded ajax content you must drop a target below the trigger within the html code. If you want your trigger below the loaded content then just pass true for the second argument in the constructor as in Ex1.
Ex5: $ajax_object->drop_target();

What to Do?

Upload the file
1 - Upload a file to your server which will be loaded into your target div. I recommend just using a php file to get started. Just keep in mind that php runs on the server so ajax is loading the output of the file not the script as would be the case with an include(); function.
2 - If you are going to use html forms in your loaded content make sure to call session_start(); at the top of the php script you are loading. This class stores all post data in a session to improve dynamic form submittal.

Create Instance
1 - Use static method to instantiate
2 - Constructor is private. *Don't Use: $var = new HypAjaxObject();

Create a Trigger
1 - Use a link href or a javascript onclick attribute and call the get_file('myfile.php'); method within the quotes.

Drop a Target
1 - If you pass true as the second argument your target has already been dropped. See Ex1
2 - Set the location of the div to load the ajax content by calling the drop_target(); method.

*/

/*
HypAjaxObject markup example - Target Window above the Trigger:

<?php $ajax_object = HypAjaxObject::create('main-ajax-target',true); ?>
<a href="<?php $ajax_object->get_file('myfile.php') ?>">Load content with link</a>

HypAjaxObject markup example - Target Window below the Trigger:
Use this method assures you can move the target div anywhere you want in the html and not worry about the class not having been loaded yet.

<?php $ajax_object2 = HypAjaxObject::create('main-ajax-target2'); ?>
<p onclick="<?php $ajax_object2->get_file('myfile.php');?>">Load content onclick</p>
<?php $ajax_object2->drop_target();?>

-------------------------------------------------------------------------------------

This is a self submitting form example to be put in a dynamically loaded php file:

<?php session_start();?>

<form name="test_form" action="?testget=yes" method="post">
<label>Test Field</label><br />
<input class="input" name="test_input" size="60" type="text" />

<!-- Hyp Ajax Fields -->
<input name="hyp_ajax_data" type="hidden" value="test_form" /><!-- Use this field to store the form post and get data in a session -->
<input name="hyp_ajax_url" type="hidden" value="<?php echo $_SERVER['REQUEST_URI']?>" /><!-- Use this to make the form self submitting -->

<input class="submit_btn" name="submit" type="submit" value="Submit" />
<input name="reset" type="submit" value="Reset" />
</form>

<p>Here is the content of the field: <strong><?php echo $_SESSION['hyp_ajax']['test_form']['post']['test_input']; ?></strong></p>
*/
?>

Super Simple Form Formatting

<style type="text/css">

#formID label { float: left; width: 100px; font-weight: bold; line-height: 24px;}
.formItem {clear: both; margin-bottom: 5px;}
.formFieldText {width: 100px; height: 20px; color: #444444;}

</style>

<form action="" method="post" id="formID">

<div class="formItem">
<label for="firstName">First Name</label>
<input class="formFieldText" type="text" value="" name="firstName" id="firstName" >
</div>

<div class="formItem">
<input type="submit" name="submit" value="Submit The Form">
</div>

</form>