5 Replies - 507 Views - Last Post: 24 July 2013 - 06:56 AM Rate Topic: -----

#1 insik  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 31-January 12

calling function on submit problem

Posted 23 July 2013 - 10:47 PM

Hi.
I'm having issue in sending email or calling function for sending email on submit.
emails are not sent after submitting.I already uploaded this in our hosting.
this is my code:
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" target="_blank" method="post"> 
					<input type="hidden" name="cmd" value="_ext-enter">
					<input type="hidden" name="redirect_cmd" value="_cart">
					
					<input type="hidden" name="address_override" value="0">
					<input type="hidden" name="upload" value="1">
					<input type="hidden" name="no_note" value="1">  
					<input type="hidden" name="business" value="prg@gmail.com">
					<input type="hidden" name="currency_code" value="USD">
					<input type="hidden" name="return" value="http://example.com/thank_you.php">   
					<input type="hidden" name="cancel_return" value="http://example.com/">   
					<input type="hidden" name="tax" value="0.04"> 
					
					<input type="hidden" name="email" value="<?php echo $_SESSION['email']; ?>">
					<input type="hidden" name="first_name" value="<?php echo $_SESSION['firstname']; ?>">
					<input type="hidden" name="last_name" value="<?php echo $_SESSION['lastname']; ?>">
					<input type="hidden" name="address1" value="<?php echo $_SESSION['address']; ?>">
					
					<input type="hidden" name="city" value="<?php echo $_SESSION['city']; ?>">
					<input type="hidden" name="state" value="<?php echo $_SESSION['state']; ?>">
					<input type="hidden" name="zip" value="<?php echo $_SESSION['zip']; ?>">
					

				<?php
				if(is_array($_SESSION['cart'])){
            	
				$max=count($_SESSION['cart']);
				for($i=0;$i<$max;$i++){
					$pid=$_SESSION['cart'][$i]['productid'];
					$q=$_SESSION['cart'][$i]['qty'];
					$pname=get_product_name($pid);
					if($q==0) continue;
			
				$price = get_price($pid);
				$subtotal = get_price($pid)*$q;
				$total = get_order_total();
				
            	
					
				?>
					<input type='hidden' name='item_number_<?php echo $i+1;?>' value='#PRG<?php echo $pid; ?>'>
					<input type="hidden" name="item_name_<?php echo $i+1; ?>" value="<?php echo $pname; ?>"> 
					<input type="hidden" name="amount_<?php echo $i+1; ?>" value="<?php echo $price; ?>"> 
					<input type="hidden" name="quantity_<?php echo $i+1; ?>" value="<?php echo $q; ?>"> 
					<input type='hidden' name='shipping_<?php echo $i+1; ?>' value='<?php echo number_format($_SESSION['paypalShipping'],2) * $q; ?>'>
					<input type="hidden" name="tax_<?php echo $i+1; ?>" value="<?php echo $price * 0.04 ?>"> 
					<?php
						}
					
					}
					?>
					
					
					
					<input type='image' src='images/button.png' name='submit' alt='Pay Now with PayPal'> 
				</form>
					
					
					<?php 			
						if(isset($_POST['submit'])){
							mailOrderBuyer(); 
							mailOrderSeller();
						}	
					?>



Is This A Good Question/Topic? 0
  • +

Replies To: calling function on submit problem

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,439
  • Joined: 08-June 10

Re: calling function on submit problem

Posted 23 July 2013 - 11:33 PM

if the form is submitted, it goes to the paypal script, not to your PHP page. (and if it returns from paypal to your script, there are usually no POST varaibles re-set).
Was This Post Helpful? 0
  • +
  • -

#3 insik  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 31-January 12

Re: calling function on submit problem

Posted 23 July 2013 - 11:41 PM

Are there ways to call a function upon submitting the form to paypal?
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,439
  • Joined: 08-June 10

Re: calling function on submit problem

Posted 24 July 2013 - 12:34 AM

not in the strict case (you can only submit to a single location).

what you can do, though, is set up an AJAX request on submit that sends the data for mailing to a script of yours.
Was This Post Helpful? 0
  • +
  • -

#5 insik  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 68
  • Joined: 31-January 12

Re: calling function on submit problem

Posted 24 July 2013 - 12:58 AM

ok Dormilich. thanks
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3098
  • View blog
  • Posts: 10,883
  • Joined: 08-August 08

Re: calling function on submit problem

Posted 24 July 2013 - 06:56 AM

insik, do you recognize that PHP functions are not called from HTML? HTML is processed by the browser, which runs on the client's computer. PHP runs on your server. These machines could be separated by thousands of miles and potentially hours of time. What happens when you submit a form is that the data is sent back to the server along with a request to run a script. What functions get called depend on the script and the data it receives from the web server.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1