extract url parameters and add them to database - wordpress

loopline

Jr. Executive VIP
Jr. VIP
Joined
Jan 25, 2009
Messages
6,210
Reaction score
3,564
Website
contactformmarketing.com
What I want to do is capture a url parameter and save it to a user friendly exportable database. Ideally Id love to do this with wordpress.

The KEY element here is I want this to happen on page load.

Im effectively trying to create a opt out database page.

So if I send someone a message and I give them link to opt out of future messages, I want them to be able to click the link and it adds them to the database without having to do anything else, then redirect them to a page of my choice.

Basically 1 click opt out.

So a url might be

http://www.domain.com/?=parameter

I want to save "parameter" to a database and then able to export that into excel.




So the user clicks on http://www.domain.com/?=parameter and the server grabs the parameter, adds it to the database and redirects them to a page that says "parameter" has been opted out, have a great day. (or whatever).

If there is a way to do this inside of wordpress that would be handy, but its not the end of the world if its outside of wordpress.

Also there is possibly a ready made solution, but Im just not aware of it, by all means if you can point me to it Im all for it.

Im NOT using a big platform like aweber etc... I am just sending messages, I need a way to handle the opt outs. Once I have the parameter in the database and export it to excel, Ive got all the rest handled.

Thoguhts?
 
After thinking about it, I don't care if the export for this data is just plain text, 1 entry per line. So maybe really the best method is to do a php script or something that does this and saves it to some database and then redirects. Then I can send them to a thank you page on my wordpress setup.
 
The problem with a param based opt-out is that it'll trigger itself whenever it's called. So a spider crawling links in an inbox, an "auto opt out" app of some kind, a next-generation inbox with previews etc. or even an accidental click would all result in said email being added to the opt-out list.

A more graceful way of doing this would be to create a page with a single input field that populates with the url parameter.

So something like - http://site.com/[email protected]

The value of mail can be echod in the form using.

PHP:
<?php
  echo $_GET['mail'];
?>

Below this form field, you create an "Opt-out" button. As soon as that is clicked, the email gets added to the DB.

This would prevent triggers from link crawlers and accidental clicks.

To implement the above in Wordpress, you can use the CF7 Database extension that allows you to utilize Contact Form 7 and add the queries to the Database.

https://github.com/mdsimpson/contact-form-7-to-database-extension
 
I already have this setup and have been using this setup for quite some time, thanks for the idea though. :)

The issue is, a lot of people think these sort of links are just to see if they are a live person or not. So they click them and do not submit the form. Then they call instead or go online and leave reviews etc.. This way I have their opt out as soon as they click.

Plus I don't think its that bad, plenty of opt out links i click in emails are single click opt out. So I think it should be ok, I just havent' yet sorted how to do it best. Thanks for the feedback though
 
I understand what you're saying. To take a URL parameter and straight up add it to database is even simpler.

Use something like -

PHP:
<?

$conn = mysql_connect("localhost", "user", "pass");
if(! $conn )
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db('database-name');

$mailparam = mysql_query( "INSERT INTO unscubscribe ('id') VALUES ('".mysql_real_escape_string($_GET['mail'])"')", $conn );

if(! $mailparam )
{
  die('Database Failed' . mysql_error());
}

echo "You have been successfully unsubscribed\n";

?>

Typed this hurriedly, please excuse typos and brevity.
 
you did that in a hurry? lol That would have taken me 2 hours to sort. Thanks! Im really slow at this sort of thing, hence the asking for help.
 
Always happy to help one of my favorite IMs.

Your list were the holy grail for me back in the day when I was a ton into SB. So thank you for that.
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock