calmchess Posted March 3, 2009 Share Posted March 3, 2009 I am generating a message to the user dependent upon wheter or not an if statement fires. the if statement is sepertated a by other html code other than the target html code that i want the message to show up in i've tried to specify a function to be called to display the message in the target html code but the message always appears at the point that I called the function.......How do I specify the point where an echo should occur when the if statement fires? Quote Link to comment Share on other sites More sharing options...
brentech Posted March 3, 2009 Share Posted March 3, 2009 A sample of the code would help a great bit. Quote Link to comment Share on other sites More sharing options...
calmchess Posted March 3, 2009 Author Share Posted March 3, 2009 the begining of the code is the target (where i want the message to appear) and the end of the code is the if statements generating the messages. </td></tr> <tr><td>CVV Number:</td><td><input type="text" name="cvv"></td></tr> <tr><td colspan="2" align="right"><A href="https://www.privatechatnow.com/authorize/popup0.html"onClick="return popup(this, 'notes')">whats this</a></td></tr> <tr><td><input type="submit" name="subtrans" value="Submit"></td></tr> </table> </form> </div> </div> </div> <?php if(isset($_POST['subtrans'])){ $card0 = $_POST['card']; $exp0 = $_POST['expmon'].$_POST['expyr']; $fname = $_POST['fname']; $lname = $_POST['lname']; $addr = $_POST['addr']; $city = $_POST['city']; $state = $_POST['state']; $zip = $_POST['zip']; $DEBUGGING = 1; # Display additional information to track down problems $TESTING = 1; # Set the testing flag so that transactions are not live $ERROR_RETRIES = 2; # Number of transactions to post if soft errors occur $auth_net_login_id = "2Sht9m67PD"; $auth_net_tran_key = "35J2rq5d6LtJ2Yg6"; $auth_net_url = "https://test.authorize.net/gateway/transact.dll"; # Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts # $auth_net_url = "https://secure.authorize.net/gateway/transact.dll"; $authnet_values = array ( "x_login" => $auth_net_login_id, "x_version" => "3.1", "x_delim_char" => "|", "x_delim_data" => "TRUE", "x_type" => "AUTH_CAPTURE", "x_method" => "CC", "x_tran_key" => $auth_net_tran_key, "x_relay_response" => "FALSE", "x_card_num" => $card0, //"4242424242424242", "x_exp_date" => $exp0, //"1209", "x_description" => "Recycled Toner Cartridges", "x_amount" => "12.23", "x_first_name" => $fname, //"Charles D.", "x_last_name" => $lname, //"Gaulle", "x_address" => $addr, //"342 N. Main Street #150", "x_city" => $city, //"Ft. Worth", "x_state" => $state, //"TX", "x_zip" => $zip, //"12345", "SpecialCode" => "Promotion: Spring Sale", ); $fields = ""; foreach( $authnet_values as $key => $value ) $fields .= "$key=" . urlencode( $value ) . "&"; echo "<hr>"; /////////////////////////////////////////////////////////// echo "<b>01: Post the transaction (see the code for specific information):</b><br>"; $ch = curl_init("https://test.authorize.net/gateway/transact.dll"); ### Uncomment the line ABOVE for test accounts or BELOW for live merchant accounts ### $ch = curl_init("https://secure.authorize.net/gateway/transact.dll"); curl_setopt($ch, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim( $fields, "& " )); // use HTTP POST to send form data curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response. ### $resp = curl_exec($ch); //execute post and get results curl_close ($ch); echo "<hr>"; /////////////////////////////////////////////////////////// echo "<b>02: Get post results:</b><br>"; echo $resp; echo "<br>"; echo "<hr>"; /////////////////////////////////////////////////////////// echo "03: Parse post results (simple approach)<br>"; $text = $resp; echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"1\">"; echo "<tr>"; echo "<td class=\"v\">"; $tok = strtok($text,"|"); while(!($tok === FALSE)){ //while ($tok) { echo " ".$tok."<br>"; $tok = strtok("|"); } echo "</td>"; echo "</tr>"; echo "</table>"; echo "<hr>"; /////////////////////////////////////////////////////////// echo "<b>04: Parse the results string into individual, meaningful segments:</b><br>"; echo "<table cellpadding=\"5\" cellspacing=\"0\" border=\"1\">"; /////////////////////////////////////////////////////////// // STATISTICAL USE ONLY: // /////////////////////////////////////////////////////////// echo "<tr>"; echo "<td class=\"q\">"; echo "Length of the returned string from Authorize.Net:"; echo "</td>"; echo "<td class=\"q\">"; echo strlen($resp); echo "</td>"; echo "</tr>"; $howMany = substr_count($resp, "|"); echo "<tr>"; echo "<td class=\"q\">"; echo "Number of delimiter characters in the returned string:"; echo "</td>"; echo "<td class=\"q\">"; echo $howMany; echo "</td>"; echo "</tr>"; /////////////////////////////////////////////////////////// $text = $resp; $h = substr_count($text, "|"); $h++; $test0 = split('\|',$resp); if($test0[2]==1){ msg1="transaction was approved"; } if($test0[2]>1){ msg0 = " transaction was declined"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.