Jump to content

Transferring Data to new PHP on clicked link


nmrudolph

Recommended Posts

I have a page that reads from a database to list employees from different states. Under each name is a link that pulls up a new window with a contact form. My goal is to get the name from that link to appear on that new window. (Which I will then use to ultimately add the name into the email that was generated so the recipient can know who the email was intended for.)

 

I've tried using the GET and POST methods but nothing seems to work. Any help would be appreciated greatly. I will name my firstborn after anything you desire.

 

I've included my code below. (The last line is what I've been primarily working with)

 

//Open Database Connection
$db = open_db_connection();
$sql = "SELECT DISTINCT 1 from users where active = 'Y' and show_on_contactus = 'Y'";
$results = mysql_query($sql, $db);
$emaillink = "<a target='main'   onclick=window.open('contactform/contactCentral.php?name=$state_row[state]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>";
if(!mysql_num_rows($results) == FALSE)

        while($row = mysql_fetch_array($results, MYSQL_BOTH))
        {
           echo "<ul id=\"directors\">\n";
           $state_sql = "SELECT * from users where active = 'Y' and show_on_contactus = 'Y' and state_full = 'indiana' order by last_name";
	   $state_results = mysql_query($state_sql, $db);
           if(!mysql_num_rows($results) == FALSE)
           {
              while($state_row = mysql_fetch_array($state_results, MYSQL_BOTH))
              {
                 echo "<li>\n";
                 echo "   <div class=\"fl dirimg\">\n";
                 if($state_row[photo] == "")
                 {
                    echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"images/exe_placeholder.jpg\" alt=\"$state_row[first_name] $state_row[last_name]\" />\n";
                 }
                 else
                 {
                    echo "<img border=\"0\" width=\"61\" height=\"85\" src=\"n2team/pictures/$state_row[photo]\" alt=\"$state_row[firstname] $state_row[last_name]\" />\n";
                 }
                 echo "   </div>\n";
                 echo "   <span class=\"fr\">$state_row[first_name] $state_row[last_name]<br />\n";
                 echo "       $state_row[title]<br />\n";
                 echo "       $state_row[city], $state_row[state]<br />\n";
			 echo "		$emaillink Contact $state_row[first_name] </a></span></li>\n";
              }

Link to comment
Share on other sites

Not sure I follow clearly on what you want(I'll try to atleast help), but you could possibly just add it to $emaillink to call the $_GET variable later on.

 

$emaillink = "<a target='main'   onclick=window.open('contactform/contactCentral.php?name=$state_row[state].&firstname=$state_row[first_name].&lastname=$state_row[last_name]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>";

 

And this should just stay as it is:

echo "		$emaillink Contact $state_row[first_name] </a></span></li>\n";

 

Then on your contactCentral.php you can get the information from $_GET for first name and last name and do whatever it is you wish to do with them.

 

Link to comment
Share on other sites

I tried changing to what you said but when I do the next page doesn't list anything in the URL.

 

In order to use the $_GET function the first and last name would be posted there wouldn't it?

 

I went ahead and tried these it anyway but nothing came up:

 

<?php echo $_GET["name"]; ?>

 

<?php echo $_GET['name=$state_row[state].&firstname=$state_row[first_name].&lastname=$state_row[last_name]']; ?>

Link to comment
Share on other sites

Move that entire $emaillink = .........

 

to under this line like so:

 

              while($state_row = mysql_fetch_array($state_results, MYSQL_BOTH))
{
$emaillink = "<a target='main'   onclick=window.open('contactform/contactCentral.php?name=$state_row[state].&firstname=$state_row[first_name].&lastname=$state_row[last_name]','popup','width=380,height=400,scrollbars=no,resizable=no,toolbar=yes,directories=no,location=no,menubar=yes,status=no,left=0,top=0'); return false>";

 

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.