Page 1 of 1

Opt-Out Script

Posted: Fri Sep 05, 2008 1:54 pm
by sddt
Hello everyone, I am a first time poster here and have what I hope to be a simple question.

I don't have much experience with php script but have enough knowledge (I think) to pull this off with some help. I am trying to create a script for an Opt-out form to remove somebody from a mailing list. Basically all I want it to do is retrieve the email to be removed from an html form and e-mail this info to an employee so he can remove it from the database. Here is the code that I am attempting to use:

Code: Select all

<?php
 
    $to_1 = "test@test.net";
    $subject = "Opt-Out Request";
    $email = $_POST['e_mail'];
    $msg = "Please remove me from your mailing list.\nE-Mail: $e_mail";
    $path = "optout_sc.php";
    $headers = "From:test@test.net\n";
    $mail_status = mail($to_1,$subject,$msg,$headers);
    if($mail_status){
        echo "$path";
    }
    else{
        echo "There has been an error processing your request";
    }
 
?>
Also, I want to create a success and failed page but am unsure how to call them from the script. As you can see I have the variable setup for it but am unsure what command to use in php to actually tell the browser to goto that url instead of just displaying it. Is there some sort of getURL command?

Thank you very much for any help!

Re: Opt-Out Script

Posted: Fri Sep 05, 2008 10:29 pm
by sddt
Anybody?

Re: Opt-Out Script

Posted: Sat Sep 06, 2008 12:14 am
by JAB Creations
Where is the email address to begin with?

I presume it's stored in a database though I don't see anything database related unless it's being done through a function.

Re: Opt-Out Script

Posted: Mon Sep 08, 2008 11:24 am
by sddt
The e-mail address to be removed is entered into an html form then submitted to this php script which notifies the employee to remove them from the database. Here is the html form code. Is this the correct way to go about doing this?

Code: Select all

<form name="form1" method="post" action="">
            <label>E-mail:
              <input type="text" name="e-mail" id="e-mail" tabindex="1">
              </label>
          </form>
          <p align="left"><a href="email.php"><img src="images/submit_btn.jpg" width="60" height="15"></a>

Re: Opt-Out Script

Posted: Mon Sep 08, 2008 12:42 pm
by JAB Creations
1.) What does the serverside code look like?

2.) Why would you have something personally do something you could have the server automate for you?

Re: Opt-Out Script

Posted: Mon Sep 08, 2008 12:46 pm
by sddt
Well, they use a mass e-mail database called CRM-Free so I am unsure what the capabilities are of actually manipulating the database like that. I was asked to set it up this way so that is exactly what I am doing. Are you familiar with this service (CRM-Free)?

Re: Opt-Out Script

Posted: Mon Sep 08, 2008 2:03 pm
by JAB Creations
You need to talk with the web developer who is handling this. Ask what they want sent to the server such as a form POST in example with an associated name (being the email address).

For example the web developer may want to handle something like this...

$_POST['email_address']

The form would need to have method="post"...
<form action="file.php" method="post">

Then the field with the email address to be removed would be...
<input name="email_address" type="text" />

So then they would simply "catch" the information by referring to it as $_POST['email_address'].

That's it, doesn't get any simpler than that.

Re: Opt-Out Script

Posted: Mon Sep 08, 2008 2:34 pm
by sddt
Ok, thanks for the info. I thought it should be an easy deal but am still having probs with their database (CRM-Free). I am going to try and get in touch with them to see if there is anything wrong on my end or maybe something on theirs. Thanks again!