Jump to content

Recommended Posts

I'm no PHP master, so I figured I would ask this question and hopefully someone out there knows how to do it without breaking a sweat (as I have been doing).

 

I have a simple email signup form that captures a name and email address. My php validator page checks the address and sends out a double opt-in email. After signing up, the user is directed to my confirmation page telling them to check their email. All I want to do is echo their name and email to this confirmation page, but it hasn't been working so far. Here is my code for the .php page and then for the confirmation page (check_email.php).

 

<?php
/* Simple email validation by TDavid at http://www.tdscripts.com/ 
for http://www.php-scripts.com/php_diary/011103.php3
If you use this code then please do not remove this header
*/

$from = $_REQUEST['visitormail'];
$name = $_POST['visitor'];
$name = $_REQUEST['visitor'];
$myemail = "maria@campuscalm.com (Maria Pascucci-Maciejewski)";
$ip = getenv("REMOTE_ADDR");
$todayis = date("l, F j, Y, g:i a") ;

$headers = "From: $myemail\n";
$headers .= "Reply-To: $myemail\n"; 
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";


// is the $from email address in valid format?
if(eregi("([[:alnum:]\.\-]+)(\@[[:alnum:]\.\-]+\.+)", $from)) {

  // create the MD5 hash
  $secret_code = 'campuscalmlist';
  $formatted_email = preg_replace("/(-|\@|\.)/", "", $from);
  $hashed = md5("$secret_code $formatted_email");

  // wait, are we verifying the email?
  if($_REQUEST['m'] != "") {
    // this is validation routine
    if($hashed == $_REQUEST['m']) {
	  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.campuscalm.com/validated.html\">";
      // add the email to your double opt-in list here
      
  
  if(file_exists("list_test.txt"))
{
$newfile = fopen("list_test.txt", "r");
    while(!feof($newfile))
   {
     $duplicate = fgetss($newfile, 255);
     // is email address submitted already on file?
        if(eregi("$from", $duplicate))
       {
         print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.campuscalm.com/duplicate.php\">";
         fclose($newfile);
         exit;
       }
    }
  fclose($newfile);
  $addemail = fopen("list_test.txt", "a");
  fputs($addemail, "$name,$from\n");
  fclose($addemail);
}
else
{
   // since file doesn't already exist, let's create for first time
   $newfile = fopen("list_test.txt", "a");
   fputs($newfile, "$from\n");
   fclose($newfile);
   chmod("list_test.txt", 0666);
}
  
  
  
  exit;
    } else {
        print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.campuscalm.com/validation_error.php\">";
    }
  } else {
    // since we aren't validating then it is time to send out validation mail

    $mail_body = "$todayis <p>\n
Hi $name,<p>\n

Thank you for subscribing to <strong>Campus Calm Connections </strong> - where
  students meet to speak out about grades, stress and personal well-being.<p><p>
To validate your email address, <a href='http://www.campuscalm.com/signup_test.php?visitor=$name&visitormail=$from&m=$hashed'>Click here.</a>

If your email program does not allow you to click on the link, copy and paste the following address into a web browser to validate your email address:  <p><p>
http://www.campuscalm.com/signup_test.php?visitor=$name&visitormail=$from&m=$hashed
<p><p>
If you have difficulties validating your email address, please reply to this email and we will add you to our database.<p><p>
Campus Calm<br>
372 Aurora Street<br>
Lancaster, New York 14086<p><p>
Campus Calm will never rent, trade or sell your email address to anyone.<p><p>
You are receiving this email from Campus Calm because you subscribed on our
  website or via e-mail. To ensure that you continue to receive emails from us,
  add maria@campuscalm.com to your address book today. To no longer receive our
  emails, respond back to this message with 'Unsubscribe from Campus Calm Connections' as the subject line.\n";




    mail($from, "Welcome to Campus Calm Connections - Email Validation", $mail_body, $headers);
      print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.campuscalm.com/check_email.php\">";
  }
} else {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.campuscalm.com/format_error.php\">";
}
?> <!-- ********** End of php script *********** -->

 

Confirmation .php page (the important part, at least...):

<?php


$from = $_POST['visitormail'];
$from = $_REQUEST['visitormail'];
$name = $_POST['visitor'];
$name = $_REQUEST['visitor'];

?> <!-- ********** End of php script *********** -->
<span class="headline2">Welcome <?php echo $visitor ?>,</span><br>
        <br>
        <span class="style1"><br>
        <br>
        Thank you for subscribing....
<span class="style1">You will receive an email shortly with a link
				     to confirm your email address:<br>
					 <strong><?php echo $from ?></strong><br>
				     <br>

	Once your email is confirmed, you will be....

 

I think I need some other code added to my .php validator/processor page so it will transmit the data to my confirmation page, but I don't know enough about it...

 

Any help would be great. Thanks

 

Shaunmacie

On the processing page, save any variables you want to use on the next page to the session.

Example: $_SESSION['name'] = $name

 

At the top of every page add session_start();

 

Then on your confirmation page, use

$name = $_SESSION['name'];

 

 

Okay, so I'm almost there but at my level it appears I need everything spelled out for me. I have it working, but it only transfers one of the variables. I have it working like this:

 

$_SESSION['transmit'] = $from;

 

But how should I have this line coded so it sends over BOTH $from and $name ?

 

Whenever I do it, it only sends the second one or it gives me an error...

 

Sorry for asking the dumb questions, but everyone has to start somewhere....

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.