Skip to content

Instantly share code, notes, and snippets.



Last active Jul 17, 2019
What would you like to do?
if( $_POST["name"] )
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"");
curl_setopt($ch, CURLOPT_POST, 1);
// example splitting a name field into first and last name bits
$pieces = explode(" ", $_POST['name']);
$last_name_parts = array_slice($pieces, 1); //each word
$last_name = implode(" ", $last_name_parts); //combined words, with space separators
// build up the lead post data here, you can combine fields into the data you are sending
// see subject for an example
curl_setopt($ch, CURLOPT_POSTFIELDS,
http_build_query(array('first_name' => $pieces[0],
'last_name' => $last_name,
'email' => $_POST['email'],
'phone' => $_POST['phone'],
'ticket_problem_type' => $_POST['problem'],
'city' => $_POST['city'],
'ticket_subject' => $_POST['device'] . " Pri: " . $_POST['priority'],
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
//redirect to thanks page
header("Location: /thanks.html");
<form action="<?php $_PHP_SELF ?>" method="POST">
Name: <input type="text" name="name" /> <br>
Email: <input type="text" name="email" /><br>
Phone: <input type="text" name="phone" /><br>
Problem: <input type="text" name="problem" /><br>
City: <input type="text" name="city" /><br>
Device Type: <select name='device'>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
Priority: <select name='priority'>
<option value="p3">Low</option>
<option value="p2">Medium</option>
<option value="p1">High</option>
<input type="submit" />

This comment has been minimized.

Copy link

@techinaflash techinaflash commented Aug 8, 2014

Can you provide an example of POSTing an invoice. I can't get the line_items to pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment