Page 1 of 1

Pass variable from one site to another

Posted: Sun Nov 07, 2010 7:46 pm
by cwkerns
I am building a website (experienced with HTML, newbie to PHP, knowledge level is limited beginner) My client is an artist host for a Cruise that you can register for on another website (I have no control over the cruise website) What I would like to do is when someone clicks on a button on my client's website to register for the cruise, it put's my client's name in the Cruise Artist field on the cruise website. here is the link to the cruise website:
http://www.ccmnow.com/2011-cruise-prici ... gistration

thanks in advance for any assistance.

Re: Pass variable from one site to another

Posted: Sun Nov 07, 2010 8:52 pm
by McInfo
Because of steps taken in recent times by both websites and browsers to prevent cross-site vulnerabilities, it may not be possible to do what you are asking.

One way to get the artist in the form is to POST the "cruiseartist" field from a form on your site to the same URL that the form on the cruise site gets submitted to. If the cruise site doesn't reject your request for coming from a different domain, it will throw the form back to the user with the artist field loaded. Unfortunately, the form will be accompanied by an error message because the form is incomplete, making this a not-so-elegant solution.

The other solution is to contact the webmaster of the cruise site and request a change to the form to either
  • allow the artist to be initialized through the URL, or
  • error silently if the only field submitted is "cruiseartist".

Re: Pass variable from one site to another

Posted: Sun Nov 07, 2010 9:28 pm
by maas
below code will do what you want, however as pointed out it will throw up validation errors, but try it and see if you can live with it...

all you need to do is set the $user variable as the artist you want passed to the cruise website

Code: Select all


<form action="http://www.ccmnow.com/index.php?Itemid=163" class="bfform defaultform" enctype="multipart/form-data" id="BF_FORM_1" method="post" name="BF_FORM_1" target="_self">

<?php
echo "<input class='inputbox' id='cruiseartist' maxlength='255' name='cruiseartist' size='30' type='hidden' value='$user'/>"; ?>

	<button id="form_submit_button" type="submit" class="button bfbutton" onclick="bf_form.formSubmit('1');return false;">Submit</button> 
 
	<input type="hidden" name="bf_s" value="f76d48f95673f722af18b3934bc655f7" />  
	<input type="hidden" name="bf_z" value="YzRjYTQyMzhhMGI5MjM4MjBkY2M1MDlhNmY3NTg0OWI=" />  
	<input type="hidden" name="c6545b22a58cd1d882c095c3efb2d486" value="1" />  
	<input type="hidden" name="option" value="com_form" /> 
	<input type="hidden" name="sid" value="" /> 
	<input type="hidden" name="spam" value="95" /> 
	<input type="hidden" name="token" value="8957" />  
	<input type="hidden" name="Itemid" value="163" /> 
	<input type="hidden" name="bf_preview_1" id="bf_preview_1" value="0" /> 
 
</form>