Jump to content

Automatically submitting a form


mtgriffiths

Recommended Posts

Hey All,

 

I have a page passes information over to another page using the post method.

 

On the page that the information is passed to i want the form that i have on that page to automatically submit to the page that it specifies on the form.

 

The code im using at the moment is:

 

<?php
$Manufacturer = $_POST['Manufacturer'];
$Model = $_POST['Model'];
$Price = $_POST['Price'];
$Quantity = $_POST['Quantity'];
$Description = $_POST['Description'];
?>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
   <input type="hidden" name="cmd" value="_xclick">
   <input type="hidden" name="business" value="mtgriffiths@googlemail.com">
   <input type="hidden" name="item_name" value="<?php echo $Manufacturer; ?>">
   <input type="hidden" name="item_number" value="<?php echo $Price; ?>">
   <input type="hidden" name="amount" value="1">
   <input type="hidden" name="on0" value="<?php echo $Model." ".$Description ?>">
   <input type="hidden" name="currency_code" value="GBP">
   <input type="hidden" name="bn" value="IC_Sample">
</form>

 

Once a button is pressed the information from the previous page is put into the variables...i then want the above form to automatically submit and take me to the paypal site specified in the form.

 

Can anybody help me?

 

Thanks in advance

 

Matthew

Link to comment
Share on other sites

I am not quite sure why you are not submitting the form when the user clicks on submit.

You cannot submit a form without user input.

 

If I understand it correctly, you just want them to see an intermediate page for a second before submitting to paypal? Or you just want to submit that on the background?

 

You could have a delay and then redirect the page to paypal.

 

So you could have an intermediate page. Say values.php

In that page you capture the variable information, and then do a header redirect to the paypal area.

 

Is that what you need?

 

 

Link to comment
Share on other sites

Hello,

 

Colombian, thats more or less what i am after.

The page will just load for a second before being redirected to paypal.

 

we4freelance do i just put that code at the bottom of the page to make it register?

 

 

I have another problem with this....i have a text box for the quantity on the previous page but it is inside another form. Is there anyway of capturing the value inside of the text box then posting it to the page that i am working on

 

Thanks again

Link to comment
Share on other sites

If that text value isn't crucial you could pass it along the URL and grab it with a GET.

If the user enters it on that page, I would make it part of the main form. You don't need to submit all the values of the main form to paypal. You can just save that one for later use. But you would need to either store that on the PHP, or as part of the main form.

 

In terms of security, you can only submit 1 form at a time with a server side language. So maybe you can store that variable in php.

I would not recommend having crucial parts of your form/application be completely dependent on JavaScript.

 

I would just redirect the page after the first post. They will submit it once, you collect the values on page 2 which has a redirect to page 3. The values can be passed without issues,  from page to page.

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.