Jump to content

please help - simple php code


jrjackson

Recommended Posts

I'm using some code from Robert Planks php tutorials. But I'm having a hard time getting them to work together:

 

I have a page called 'career.php' and it has this code at the top of the page:

 

<?php
$f = $_GET["f"];
if ($f) {
setcookie("f", "", time()-3600);
setcookie("f", $f, time()+3600*24*30);
}
else $f = $_COOKIE["f"];
if (!$f) $f = "Friend";
?>

 

If I put

<?php echo $f; ?>

in the career.php page and if I go to http://www.MYDOMAIN.com/career.php?f=Fred it writes their name in the page. So this part is working fine.

 

2nd PHP file I created is called "now-hiring.php" and I placed the following code in the php file:

 

<?php
// URL to redirect to
$url = "http://www.MYDOMAIN.com/career.php";
if (isset($_GET["firstname"])) {
   $user = $_GET["firstname"] . "," . $_GET["state"] . "," . $_GET["email"];
// Filename to store the list of viewers
$filename = "viewers.txt";
// Try to write to it
@touch($filename);
if (!is_writable($filename)) {
die("Cannot write to $filename... please chmod it to 666.");
}
// Read the viewers file
$viewers = array_map("trim", file($filename));
// Add this person to the list of viewers
$viewers[] = $user;
// Remove duplicates
$viewers = array_unique($viewers);
// Write back to the text file
$fp = fopen($filename, "w");
fwrite($fp, implode("\n", $viewers));
fclose($fp);
}
// Redirect to the URL
header("Location:$url"); die();
?>

 

The above php file simply writes the data; firstname, state and email to a text file named 'viewers.txt' - this is helpful in seeing who has opened my emails.

 

My email program uses the following format for customizing outgoing emails:

 

(!*FIRSTNAME*!)

(!*STATE*!)

(!*EMAIL*!)

 

I'm trying to figure out what URL code I should be using in my email program. I have their data; firstname, state and email already.

 

Here is what I thought the URL would look like that I email to people:

 

http://www.MYDOMAIN.com/page.php?firstname={!firstname}&state={!state}&email={!email}

 

The end result of all this code is to:

 

1] write the; firstname, state and email to the text file viewers.txt so I know has opened my emails.

 

2] echo their; firstname and state on my php page making the page seem customized for them.

 

I hope this all makes sense to someone and that someone can help me.

 

J.R.

Link to comment
Share on other sites

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.