Jump to content

PHP email help?


champbronc2

Recommended Posts

<? 
session_start();
?>
<? include('header.php'); ?>
<?
include('config.php');
if (isset($_POST["username"])) {
$usernamed = limpiar($_POST["username"]);
$sql = "SELECT confirmed FROM users WHERE username = '$usernamed'";
$sql2 = mysql_query($sql) or die(mysql_error());
$sql3 = mysql_fetch_array($sql2) or die(mysql_error());
if ($sql3 == 1){
echo ("<b>Your account is already confirmed!</b>");
} else {
$checkpemail = mysql_query("SELECT * FROM users WHERE username = '$usernamed'");
$pemail_exist = mysql_num_rows($checkpemail);

if ($pemail_exist<1) {
echo "Username doesnt exist.";
exit();
} else {
$coded = mysql_query("SELECT ccode FROM users WHERE username = '$usernamed'") or die(mysql_error());  
$code = mysql_fetch_array($coded) or die(mysql_error());
$emaild = mysql_query("SELECT email FROM users WHERE username = '$usernamed'") or die(mysql_error());
$email = mysql_fetch_array($emaild) or die(mysql_error());
$to = "$emaild";
$subject = "ChampBux Registration Confirmation for $usernamed";
$message = "Hello $firstname \n\nYou have been registered at ChampBux with the username $usernamed\n\nIf that is incorrect and you have not registered for ChampBux please disregard this email.\n\nConfirm your email address by copying and pasting the following link into your URL bar. \n\n http://www.champbux.com/verify.php?code=$coded";
$headers = "From: $SITEEMAIL\r\n";
$mail_sent = @mail( $to, $subject, $message, $headers );
"X-Mailer: php";
if (mail($to, $subject, $message, $headers)) {
  echo("<p>Message successfully sent! Check your spam box too!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}
}
}
}
?>
<div align="center"><div id="form">
<form action="resend.php" method="POST">

<h2>Did not receive your confirmation email? Have it resent here!</h2>
<fieldset>
<table width="400" border="0" align="center">
  <tr>
    <td width="150" align="left"><p><label>Username</label></p></td>
    <td width="250" align="left"><input type='text' size='15' maxlength='150' name='username' autocomplete="off" value="" tabindex="1" /></td>
  </tr>
  <tr>
    <td width="150" align="left"> </td>
    <td width="250" align="center"><input type="submit" value="Resend" class="submit" tabindex="4" />
  </form>
  </table>
</fieldset>
</div></div>
<? include('footer.php'); ?>

 

No matter what I always get Message Delivery Failed. What is wrong?

 

Also, if the username isn't found in the database how can i have it echo "User not found". Right now the code will just echo the header for some reason if I enter an invalid username. If I put a valid username it fails to send.

Link to comment
https://forums.phpfreaks.com/topic/130606-php-email-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.