wheres the error??
Posted: Sat Dec 06, 2003 10:16 pm
Hi, I am made a page that sends out email with the message of whatever i typed into the textarea, but when i tried to put a simple password on the page, it didnt work. I just wanna make it so you have to type in a password, and if its correct, then echo the other textarea where i can send out the email. Heres what I have got (There's no parse error, it just doesnt work)
Code: Select all
<body>
<form method="post" action="admin.php">
<p>Password: <input type="password" name="password" size="20"></p>
<p><input type="submit" value="submit" name="submit"></p>
</form>
<?
if($submit){
if($_POST[$password] == "poop"){
echo '
<form method="post" action="admin.php">
<p><textarea rows="5" name="tidbit" cols="20"></textarea>
<p><input type="submit" value="Submit" name="B1"></p>
<p><input type="reset" value="Reset" name="B2"></p>
</form>
';
}
if($_POST[tidbit] != "") {
mysql_connect("localhost","username","password") or die ("Unable to connect to MySQL server.");
$db = mysql_select_db("database") or die ("Unable to select requested database.");
$result = mysql_query("SELECT email FROM members") or die("Invalid query: " . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
if(mail($line[email], "Your weekly TidBit", $_POST["tidbit"], "From: webmaster@tidbitfacts.com")){
echo "sent";
}
else
echo "not sent";
}}
else
echo 'That password is incorrect!';
}
?>
</body>