Hi All:
I have written or rather modified a script from a tutorial I did to work for my needs, and when I try to turn the email variable into a link for example a href=mailto: it doesn't work. I need it to grab the email address that is associated with the id in which the script is calling. Below I have posted my script if anyone has an idea what the problem is. I have highlighted in red the part I have the problem with. If anybody out there can help me with this, that would be grand.
$page_title = 'View a Yachtie and Download CV';
include ('./includes/header.html');
// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view_users.php
$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
$id = $_POST['id'];
} else { // No valid ID, kill the script.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
include ('./includes/footer.html');
exit();
}
require_once ('../mysql_connect.php'); // Connect to the db.
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
if ($_POST['sure'] == 'Yes') { // Delete them.
// Make the query.
$query = "DELETE FROM captains WHERE user_id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
// Print a message.
echo '<h1 id="mainhead">View a Yachtie</h1>
<p>The user has been deleted.</p><p><br /><br /></p>';
} else { // If the query did not run OK.
echo '<h1 id="mainhead">System Error</h1>
<p class="error">The user could not be deleted due to a system error.</p>'; // Public message.
echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message.
}
} else { // Wasn't sure about deleting the user.
echo '<h1 id="mainhead">View a Yachtie</h1>
<p>The user has NOT been deleted.</p><p><br /><br /></p>';
}
} else { // Show the form.
// Retrieve the user's information.
$query = "SELECT CONCAT(first_name, ' ', last_name, '<p><br><b>E-Mail Address:</b></p><a href=\"mailto:$email\">$email ', email, '<p><br><b>Phone Number:</b></p> ', phone_1, '<p><br><b>A Second Number:</b></p> ', phone_2, '<td valign=top><p><br><b>What Ticket:</b></p> ', ticket, '<p><br><b>Nationality:</b></p>', nationality, '<p><br><b>Position Desired:</b></p>', position, '<p><br><b>Date you Registered:</b></p> ', DATE_FORMAT(registration_date, '%d %M %Y')) FROM captains WHERE user_id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_num_rows($result) == 1) { // Valid user ID, show the form.
// Get the user's information.
$row = mysql_fetch_array ($result, MYSQL_NUM);
// Create the form.
echo '<h1>View Yachtie</h1>
<form action="view_yachtie.php" method="post">
<h3> </h3>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
<table border="0" width="100%" id="table1" cellspacing="1">
<tr>
<td><p><br><b>Name:</b><br></p> ' . $row[0] . ' </td>
</table>
</form>';
} else { // Not a valid user ID.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}
} // End of the main Submit conditional.
mysql_close(); // Close the database connection.
include ('./includes/footer.html');
?>
I have written or rather modified a script from a tutorial I did to work for my needs, and when I try to turn the email variable into a link for example a href=mailto: it doesn't work. I need it to grab the email address that is associated with the id in which the script is calling. Below I have posted my script if anyone has an idea what the problem is. I have highlighted in red the part I have the problem with. If anybody out there can help me with this, that would be grand.
$page_title = 'View a Yachtie and Download CV';
include ('./includes/header.html');
// Check for a valid user ID, through GET or POST.
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // Accessed through view_users.php
$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form has been submitted.
$id = $_POST['id'];
} else { // No valid ID, kill the script.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
include ('./includes/footer.html');
exit();
}
require_once ('../mysql_connect.php'); // Connect to the db.
// Check if the form has been submitted.
if (isset($_POST['submitted'])) {
if ($_POST['sure'] == 'Yes') { // Delete them.
// Make the query.
$query = "DELETE FROM captains WHERE user_id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected_rows() == 1) { // If it ran OK.
// Print a message.
echo '<h1 id="mainhead">View a Yachtie</h1>
<p>The user has been deleted.</p><p><br /><br /></p>';
} else { // If the query did not run OK.
echo '<h1 id="mainhead">System Error</h1>
<p class="error">The user could not be deleted due to a system error.</p>'; // Public message.
echo '<p>' . mysql_error() . '<br /><br />Query: ' . $query . '</p>'; // Debugging message.
}
} else { // Wasn't sure about deleting the user.
echo '<h1 id="mainhead">View a Yachtie</h1>
<p>The user has NOT been deleted.</p><p><br /><br /></p>';
}
} else { // Show the form.
// Retrieve the user's information.
$query = "SELECT CONCAT(first_name, ' ', last_name, '<p><br><b>E-Mail Address:</b></p><a href=\"mailto:$email\">$email ', email, '<p><br><b>Phone Number:</b></p> ', phone_1, '<p><br><b>A Second Number:</b></p> ', phone_2, '<td valign=top><p><br><b>What Ticket:</b></p> ', ticket, '<p><br><b>Nationality:</b></p>', nationality, '<p><br><b>Position Desired:</b></p>', position, '<p><br><b>Date you Registered:</b></p> ', DATE_FORMAT(registration_date, '%d %M %Y')) FROM captains WHERE user_id=$id";
$result = @mysql_query ($query); // Run the query.
if (mysql_num_rows($result) == 1) { // Valid user ID, show the form.
// Get the user's information.
$row = mysql_fetch_array ($result, MYSQL_NUM);
// Create the form.
echo '<h1>View Yachtie</h1>
<form action="view_yachtie.php" method="post">
<h3> </h3>
<input type="hidden" name="submitted" value="TRUE" />
<input type="hidden" name="id" value="' . $id . '" />
<table border="0" width="100%" id="table1" cellspacing="1">
<tr>
<td><p><br><b>Name:</b><br></p> ' . $row[0] . ' </td>
</table>
</form>';
} else { // Not a valid user ID.
echo '<h1 id="mainhead">Page Error</h1>
<p class="error">This page has been accessed in error.</p><p><br /><br /></p>';
}
} // End of the main Submit conditional.
mysql_close(); // Close the database connection.
include ('./includes/footer.html');
?>
Comment