Solved

The impossible html file

Posted on 2003-11-19
10
276 Views
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.

~sarevok9~
0
Comment
Question by:sarevok9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
10 Comments
 
LVL 1

Expert Comment

by:Witchazel
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 :)

-w
0
 
LVL 11

Accepted Solution

by:
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:

"www.site1.com/cgi-bin/remove-me.cgi", "POST", "email"
"site2.net/removeit.asp", "GET", "email"
"www2.site3.com/", "POST", "user"
"removals.site4.net/removeme.php", "GET", "u"
"site5.net/email/delete-email.php.", "POST", "e"
"www.site6.com/email/management/unsub.asp", "POST", "email"

etc.

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

<html>
<head></head>
<body>
<?php
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" );
    }
    else
      fputs($fs, "GET $path?$data HTTP/1.1")

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

    echo "<pre>$response</pre>";
    fclose($fs);
  }
 
  fclose( $fp );
}
else
{
?>
<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>
</form>
<?php
}
?>
</body>
</html>

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: http://www.zend.com/zend/spotlight/mimocsumissions.php
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9783684
WH, I also thought about using JS and an iframe, but decided it would be too unwieldy/unreliable.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:Witchazel
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.
(e.g.  http://www.badspammers.com/unsubscribe.html?email=witch@hazel.com)

-w
0
 
LVL 11

Expert Comment

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

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

Author Comment

by:sarevok9
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
0
 

Author Comment

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

Expert Comment

by:Zontar
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.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

617 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