Hi,

I am trying to post a link to the following website on my blog:

http://donate.ifrc.org/

the default option for cause you would like to donate to is: haiti.

Id like to edit the url so that when someone clicks it the selected option should be Pakistan. Maybe something like:

http://donate.ifrc.org/?desc="Pakistan: monsoon floods"

is there a way to do this?

thanks
f

Dani AI

Generated

Quick summary for : a link will only pre-select a dropdown if the donation page either accepts a query parameter for that field or exposes a per-cause URL. The first step is to inspect the donation page with developer tools (right-click > Inspect). Note the form's action, its method (GET or POST), the select element's name attribute, and the option value for Pakistan. If the form uses GET a direct link is possible; if it uses POST an intermediary page that submits the selection is needed.

If the form uses GET and the select name is, for example, cause with option value pakistan, the resulting URL will look like https://donation.example.org/?cause=pakistan (replace the domain/field names with those discovered in devtools). If the site already provides per-cause/share links, prefer those — they are more stable than hacks.

If the form requires POST, host a tiny page that auto-submits a hidden form to the donation endpoint (this is the reliable way to POST a specific value into a third-party form):

<!doctype html>
<html>
  <body onload="document.forms[0].submit()">
    <form action="https://donation.example.org/" method="post">
      <input type="hidden" name="cause" value="pakistan">
      <!-- add other required hidden fields here -->
      <noscript>
        <p>Click to continue to the donation page.</p>
        <button type="submit">Continue</button>
      </noscript>
    </form>
  </body>
</html>

Notes and cautions: a server-side Location redirect produces a GET only, so use it only if the target accepts GET. When building redirects encode parameters with URL-encoding (do not use SQL-escaping functions for this). Normal HTML form POSTs to another domain are allowed by browsers (AJAX is subject to CORS). Test thoroughly and respect the charity's terms — if an official per-cause URL or share button exists, use that. 's redirect idea points in the right direction; verify method/field names and use proper encoding before publishing.

Recommended Answers

All 2 Replies

You could do it through a form which sends the information to a php-script which redirects the user to the donation site. The script could look something like this:

$desc = mysql_real_escape_string($_GET['desc']);
$redirect = "http://donate.ifrc.org/?desc=".$redirect;

header("location: $redirect");

Or you could retrieve the values by JavaScript but I guess this is the safer way to go since people might have JavaScript turned off in their browser. :)

If your problem has been solved, please also mark the thread as solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.