The impossible html file

Posted on 2003-11-19
Last Modified: 2010-04-09
Okay I'm certified in html and this one still boggles me and haunts me at night.  

Okay i am making a site for a client and one for myself and i ran into the same problem.

Now when making a form to submit data to a remote source (supposing they dont filter it (using the post action) you just use action whatever.php

what if your making a script like me where im (trying) to create a script that will mass unsubscribe users from newsletters and other unwanted junk mail (my list of cgi's and php url's to submit to is about 300) and to make a button for each seems foolhardy,  so i suppose that my question is this,  how would i (with one button) submit that same email address to the abovementioned remove sections... with a single click.

I need to write a (preferably) client side program to do this. javascript vbscript and plain old html.  for server side you could use cgi or possibly php.... im fluent in all but i cannot seem to get multiple functions and variables into 1 form.

Question by:sarevok9
  • 4
  • 2
  • 2

Expert Comment

ID: 9783446
well, not sure best way but you make an iframe and loop thru posting in it

if you are using jscript you can create the iframes on the fly too and post them

then you can here that nice redirect click sound 300 times :)

LVL 11

Accepted Solution

Zontar earned 500 total points
ID: 9783627
I would definitely use a serverside script for this.

IN PHP you can use fsockopen() and fputs() to send a HTTP POST or GET to a script.

Before the script can be written, you must know what the exact requirements are for each email-removal script are:

1. complete URL of the script
2. required fieldname(s)/value(s)
3. submission method (GET or POST)

Do you have this info already available in an easy-to-read format such as a comma-delimited text file or a database table?

I will assume that:

1. each script requires only a single field/value (the email address to be removed)
2. the info for each removal script is stored in a text file named "remove-scripts.txt" in the following format:

url, method, fieldname

one entry per line, no skipped lines. for example:

"", "POST", "email"
"", "GET", "email"
"", "POST", "user"
"", "GET", "u"
"", "POST", "e"
"", "POST", "email"


Source of mass-remove.php. Warning: I am doing no error-checkiung whatsoever in this script.

if( isset($_POST["email"]) )
  $email = $_POST["email"];

  $fp = fopen( realpath("remove-scripts.txt") );

  while( !eof($fp) )
    $line = fgets($fp);
    list($url, $method, $field) = each( explode(",", $line) );

    $domain = substr($url, 0, strpos("/", $url));
    $path = strstr($url, "/");

    $data = $field . "=" . urlencode($email);
    $response = "";

    $fs = fsockopen($domain, 80, &$errno, &$errstr, 120);

    if($method == "POST")
      fputs($fs, "POST $path HTTP/1.1\r\n");
      fputs($fs, "Content-type: application/x-www-form-urlencoded\r\n");
      fputs($fs, "Content-length: " . strlen($data) . "\r\n\r\n" );
      fputs( $fp, "$data\r\n\r\n" );
      fputs($fs, "GET $path?$data HTTP/1.1")

    while( !feof($fs) )
      $response .= fgets( $fp, 1024 );

    echo "<pre>$response</pre>";
  fclose( $fp );
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="POST">
<p>Your email: <input type="text" name="email"></p>
<p><input type="submit" value="Unsubscribe Me"></p>

This may not be 100% accurate, as I've just dashed it off the top of my head, but it should serve to give you a fair idea of what needs to be done.

An article you may find helpful:
LVL 11

Expert Comment

ID: 9783684
WH, I also thought about using JS and an iframe, but decided it would be too unwieldy/unreliable.

Expert Comment

ID: 9783721
i definately agree with zontar,  while it would be possible to do client side (hafta be ie to be close to stable), server side will make your life much easier :)

if you only need to to post a few forms, iframe would be great, 300 is gonna go poof.

if you just need to hit the url of the pages, you could loop thru and load them in javascript, but if you need to post you will still have problems.

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

LVL 11

Expert Comment

ID: 9783865
> hafta be ie to be close to stable

What causes you to make this (IMO unwarranted) assumption?

Author Comment

ID: 9783940
in my own expirence a lot of server side includes (regardless of language) are left out by mozilla and netscape communicator,  however navigator and mozilla firebird work well except when it comes to external css.... which they occ. hiccup on

Author Comment

ID: 9783946
Zontar if you error check that and make it a working script you got the points and a extra 250.
LVL 11

Expert Comment

ID: 9784040
> in my own expirence a lot of server side includes (regardless of language) are left out by mozilla and netscape communicator,  however navigator and mozilla firebird work well except when it comes to external css.... which they occ. hiccup on

This is a server issue, not a browser issue, since browsers don't "see" include files, only what the include files send to the browser. If the SSIs generates valid (not just "looks okay in MSIE") HTML, there's no problem. CSS "hiccups" are caused by servers that send CSS as the wrong mimetype -- many servers it as plaintext or text/html whereas the correct type is text/css. (MSIE assumes that a .css extension = CSS. This may sound convenient, but it's NOT a good idea.) Add the correct mimetype to your server config and the problem will go away.

For Apache, just add

AddType text/css .css

to your .htaccess file or make the corresponding change to the master Apache config file. For IIS, you'll need to add the type in IIS Manager.

>  Zontar if you error check that and make it a working script you got the points and a extra 250.

Give me some sample data for testing.

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now