Jump to content

Recommended Posts

I have a problem with this script (resultDetail.php). It's not receiving $email from index.php. I think my mistake is in the index.php, but I'm not really sure. Any help would be appreciated. Thanks.

 


<html>
<head>
<title>Tri-Lakes Medical Center's Employee Directory</title>
</head>
<body>
<?php
//index.php
$link = mysql_connect("localhost", "********", "*****");
if (!$link)
die ("Couldn't connect to mySQL");
$database = "profiles";
mysql_select_db($database, $link) or die ("Couldn't open $database");

$query = "SELECT * FROM `departments` ORDER BY `name`";
$resultdept = mysql_query($query);
?>
<div align="center">
<h1 align="center">View Profiles</h1>
<?php
while ($dept = mysql_fetch_row($resultdept)) {?>
  <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="450" id="AutoNumber1" bgcolor="#0099CC" bordercolorlight="#000099" bordercolordark="#3333CC">
  <tr><td width="450"><b><strong><?php print $dept[0];?></strong></b></td></tr>
<?php 
$query="SELECT * FROM `users` WHERE `department` = '$dept[0]' ORDER BY `lname`";
$result = mysql_query($query);
while ($row = mysql_fetch_row($result)) {?>
  <tr>
    <td width="400"><font size="2" color="#FFFFFF"><p align="center"><b><?php print ("$row[0] $row[1] ($row[2])");?></b></font></p></td>
    <td width="50"><p align="center"><input type="button" style="border-style:ridge; border-width:1; color: #FFFFFF; font-size: 8pt; background-color: #3366CC" value="View" onClick="window.open('resultDetail.php?email=<?php print $row[2];?>','mywindow','width=700,height=500,scrollbars=yes')"></p></td>
  </tr>
<?php 
}//Ends inner while
?></table><br><?php
}//Ends outer while?>
</div>
</body>
</html>

 

<?php
//resultDetail.php
$sql_server= "localhost";
$sql_user = "*******";
$sql_pass = "******";
$db = "profiles";
$root_url="http://www.trilakesmc.com/intranet/profiles/images/"; //Root url to the images directory (with trailing slash)

$link = mysql_connect($sql_server, $sql_user, $sql_pass);
if (! $link)
        die ("Couldn't connect to mySQL");

mysql_select_db($db, $link);

$query = "SELECT * FROM users WHERE email = '$email'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
<html>
<head>
<title>Details for <?php print ("$row[0] $row[1]");?></title>
</head>
<h2 align="center"><font color="#000000"><?php print ("$row[0] $row[1] ($row[2])");?></font></h2>
<body text="#FFFFFF"><br><br>
<?php
for ($i = 0; $i < 8; $i++) {
if ($row[$i] =="")
$row[$i] = "Not Specified";
}?>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="600" id="AutoNumber1" bgcolor="#0099CC" bordercolorlight="#000099" bordercolordark="#3333CC">
  <tr>
    <td width=150><p align="right">Name:</p></td><td width=450><?php print ("$row[0] $row[1]");?></td>
  </tr><tr>
    <td width=150><p align="right">Email:</p></td><td width=450><a href="mailto:<?php print $row[2];?>"><?php print $row[2];?></a></td>
  </tr><tr>
    <td width=150><p align="right">Business Phone:</p></td><td width=450><?php print $row[5];?></td>
  </tr><tr>
    <td width=150><p align="right">Department:</p></td><td width=450><?php print $row[3];?></td>
  </tr><tr>
    <td width=150><p align="right">Picture:</p></td><td width=450><?php 
if ($row[6]=="Not Specified") { 
print ("Not Specified");
}
else {
?><p align="center"><img src="<?php print $root_url; print $row[6];?>"></p><?php }?></td>
  </tr><tr>
    <td width=150><p align="right">Hobbies:</p></td><td width=450><?php print $row[4]?></td
  </tr>
</table>
<form><input type="button" onClick="window.open('edit.php?email=<?php print $row[2];?>','mywindow','width=700,height=500,scrollbars=yes')" name="edit" value="Edit Profile" style="font-size: 2mm"</form><br>
<form><input type="button" onClick="window.close()" name="close" value="Close Window"></form>
</div>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/159136-solved-php-varible-passing-problem/
Share on other sites

2nd page, add:

<?php
//resultDetail.php
$sql_server= "localhost";
$sql_user = "*******";
$sql_pass = "******";
$db = "profiles";
$root_url="http://www.trilakesmc.com/intranet/profiles/images/"; //Root url to the images directory (with trailing slash)
// ADD THIS LINE
$email=$_GET['email'];
// END ADD
$link = mysql_connect($sql_server, $sql_user, $sql_pass);
if (! $link)
        die ("Couldn't connect to mySQL");

mysql_select_db($db, $link);

$query = "SELECT * FROM users WHERE email = '$email'";
$result = mysql_query($query);
$row = mysql_fetch_row($result);
?>
<html>
<head>
<title>Details for <?php print ("$row[0] $row[1]");?></title>
</head>
<h2 align="center"><font color="#000000"><?php print ("$row[0] $row[1] ($row[2])");?></font></h2>
<body text="#FFFFFF"><br><br>
<?php
for ($i = 0; $i < 8; $i++) {
if ($row[$i] =="")
   $row[$i] = "Not Specified";
}?>
<div align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="600" id="AutoNumber1" bgcolor="#0099CC" bordercolorlight="#000099" bordercolordark="#3333CC">
  <tr>
    <td width=150><p align="right">Name:</p></td><td width=450><?php print ("$row[0] $row[1]");?></td>
  </tr><tr>
    <td width=150><p align="right">Email:</p></td><td width=450><a href="mailto:<?php print $row[2];?>"><?php print $row[2];?></a></td>
  </tr><tr>
    <td width=150><p align="right">Business Phone:</p></td><td width=450><?php print $row[5];?></td>
  </tr><tr>
    <td width=150><p align="right">Department:</p></td><td width=450><?php print $row[3];?></td>
  </tr><tr>
    <td width=150><p align="right">Picture:</p></td><td width=450><?php 
if ($row[6]=="Not Specified") { 
   print ("Not Specified");
}
else {
   ?><p align="center"><img src="<?php print $root_url; print $row[6];?>"></p><?php }?></td>
  </tr><tr>
    <td width=150><p align="right">Hobbies:</p></td><td width=450><?php print $row[4]?></td
  </tr>
</table>
<form><input type="button" onClick="window.open('edit.php?email=<?php print $row[2];?>','mywindow','width=700,height=500,scrollbars=yes')" name="edit" value="Edit Profile" style="font-size: 2mm"</form><br>
<form><input type="button" onClick="window.close()" name="close" value="Close Window"></form>
</div>
</body>
</html>
?>

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.