You are here: last record in DB « PHP Language « IT news, forums, messages
last record in DB

Posted by Kevin Raleigh on 07/16/07 00:45

After my data passes all validation I load it into the db
Now I need that record Id so that I can send it in an email for registration
purposes. I am using the following to read that info:

//code:
//****************************************
$check = mysql_query("SELECT username, id FROM user WHERE username =
'$userName'")or die(mysql_error());

//Gives error if user dosen't exist
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database. ');
}

while($info = mysql_fetch_array( $check )){
$dbUserName = stripslashes($info['username']);

//gives error if the password is wrong
if ($userName != $dbUserName) {
die('This user has not registered yet!');
} else{
$userId = $info['id'];
}
}
//end code
//**********************************************

I fail on the check
$check2 = mysql_num_rows($check);
if ($check2 == 0) {
die('That user does not exist in our database. ');
}
Is the logic wrong?

But the logic below passes but when I pass the id in the email link there is
no data in the variable
if ($userName != $dbUserName) {
die('This user has not registered yet!');
} else{
$userId = $info['id'];
}
}

when I put the following code in a function it won't send and I get the
header error when I use
header(location: )
//email code
//**************************************************

require("php/class.phpmailer.php");

$mail = new PHPMailer();

//$mail->IsSMTP();

// set mailer to use SMTP
$mail->Host = "relay-hosting.securesever.net"; // SMTP servers
$mail->Port = 3535;
$user = $_POST['fName'] . " " . $_POST['lName'];
$mail->From = $_POST['email'];
$mail->FromName = $user;
$mail->AddAddress("kraleigh@sbcglobal.net", "Kevin Raleigh");
//$mail->AddAddress("ellen@example.com");

// name is optional
//$mail->AddReplyTo("info@example.com", "Information");

// set word wrap to 50 characters
$mail->WordWrap = 50;

// add attachments
//$mail->AddAttachment("/var/tmp/file.tar.gz");
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");

// optional name
$mail->IsHTML(true);
$myEmail = $_POST['email'];

// set email format to HTML
$mail->Subject = "Registration for". $user;
$emailString = "http://www.1purpose-bethel.org/validate?id=" . $info['id']
.. "&code=" . $secureID;

$myBody = "Registrant: $user <br/>";
$myBody .= "Email: $myEmail<br/>";
$myBody .= "<br/><br/><br />";
$myBody .= "$emailString";

$mail->Body = $myBody;
$mail->AltBody = "This is the body in plain text for non-HTML mail
clients";

if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

//header('Location: success.php');
?>
<script language="javascript">window.location="success.php"</script>
<?php
//end code email
//*************************************************************8
I get the $secureID variable value but not the $info['id'] value


insight would be appreciated
thank you
Kevin

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация