I want to email user details from my admin area with little effort (ie, not having to copy and paste them into a email) i have the details in a database and what to be able to select a username and send them their details (to the email i have stored for them)
this is the code i’ve been using:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bullman : Admin Panel : Edit a Page</title>
<link rel="stylesheet" type="text/css" href="adminstyle.css">
</head>
<body>
<table width="920" border="0" align="center" cellpadding="5" bgcolor="#FFFFFF" class="tablestyle1">
<tr align="left" valign="top">
<td colspan="2"><img src="logo.jpg" alt="Bullman" /></td>
</tr>
<tr align="left" valign="top">
<td width="160"><table width="160" border="0" cellpadding="10" cellspacing="5">
<tr>
<td valign="top"><div align="left"><a href="admin.php" target="_self" class="tablestyle2">Home</a></div></td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"> </td>
</tr>
</table></td>
<td width="647"><table width="710" border="0" cellpadding="10" cellspacing="8" style="tablestyle1">
<tr>
<td><div class="admintitle"> Admin Area : Edit a Page</div></td>
</tr>
<tr class="tablestylebackground">
<td bgcolor="#FFFFFF"><p></p>
<?php
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("mysql4.namesco.net","bullmanimcom","hedge");
//select which database you want to edit
mysql_select_db("bullmanimcom");
//If cmd has not been initialized
if(!isset($cmd))
{
//display all the news
$result = mysql_query("select * from users order by UserID");
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
//grab the title and the ID of the news
$username=$r["username"];//take out the username
$password=$r["password"];//take out the password
$Email=$r["Email"];//take out the email
$UserID=$r["UserID"];//take out the id
//make the title a link
echo "<a href='usersend.php?cmd=edit&UserID=$UserID'>$username - <b>Edit</b></a>";
echo "<br>";
}
}
?>
<?
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["UserID"];
$sql = "SELECT * FROM users WHERE UserID=$UserID";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="usersend2.php" method="post">
<input type=hidden name="UserID" value="<?php echo $myrow["UserID"] ?>" />
<div class="liststyle"> <strong>Email: </strong><?php echo $myrow["Email"] ?></div>
<div class="liststyle"> <strong>Username: </strong><?php echo $myrow["username"] ?></div>
<div class="liststyle"> <strong>Password: </strong><?php echo $myrow["password"] ?></div>
<br />
<input type="hidden" name="cmd" value="edit" />
<input type="submit" name="submit" value="submit" />
</p>
</form>
<? } ?>
<?
if (isset($_POST["$submit"]))
$to = $_POST['Email'];
$subject = "Client Registration";
$username = $_POST['username'];
$password = $_POST['password'];
$body = "username: $username
password: $password
";
echo "Data has been submitted";
mail($to, $subject, $body);
} else {
echo "There was a error when submiting your data, please retry.";
}
?>
</td>
</tr>
</table></td>
</tr>
</table>
<p> </p>
<p> </p>
</body>
</html>
Any ideas where this is going wrong?