nmrudolph Posted April 20, 2011 Share Posted April 20, 2011 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"; } Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/ Share on other sites More sharing options...
Skewled Posted April 20, 2011 Share Posted April 20, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1203846 Share on other sites More sharing options...
nmrudolph Posted April 20, 2011 Author Share Posted April 20, 2011 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]']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1203974 Share on other sites More sharing options...
Skewled Posted April 20, 2011 Share Posted April 20, 2011 <?php echo $_GET["name"]; ?> Should be: <?php echo $_GET["firstname"]; ?> <?php echo $_GET["lastname"]; ?> Since that's what we're sending. As for displaying it in the title bar for the webpage for that window I dunno. Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1204109 Share on other sites More sharing options...
nmrudolph Posted April 20, 2011 Author Share Posted April 20, 2011 Tried that and all that showed up on the next page was a single period... [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1204115 Share on other sites More sharing options...
Skewled Posted April 20, 2011 Share Posted April 20, 2011 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1204122 Share on other sites More sharing options...
nmrudolph Posted April 20, 2011 Author Share Posted April 20, 2011 kadeous, you are a god among men. It worked! Now I have to figure out how to add that into the email that gets generated, but that should be much more straightforward. Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1204142 Share on other sites More sharing options...
Skewled Posted April 21, 2011 Share Posted April 21, 2011 Your welcome, make sure you click this solved. Quote Link to comment https://forums.phpfreaks.com/topic/234209-transferring-data-to-new-php-on-clicked-link/#findComment-1204314 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.