PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > alt.comp.lang.php > last record in DB
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
last record in DB

Réponse
 
LinkBack Outils de la discussion
Vieux 16/07/2007, 01h45   #1 (permalink)
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut last record in DB

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


  Réponse avec citation
Vieux 16/07/2007, 11h21   #2 (permalink)
Virginner
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: last record in DB

"Kevin Raleigh" <kraleigh@sbcglobal.net> wrote in message
news:h6qdnQqVnN48IwfbnZ2dnUVZ_sWdnZ2d@giganews.com ...
> 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


check the PHP manual for

mysql_insert_id()



  Réponse avec citation
Vieux 17/07/2007, 03h21   #3 (permalink)
Kevin Raleigh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: last record in DB

Thank You
Kevin

"Virginner" <theDOTbin@virginLOSEIT.net> wrote in message
news:XEHmi.8888$XR.5300@newsfe4-win.ntli.net...
> "Kevin Raleigh" <kraleigh@sbcglobal.net> wrote in message
> news:h6qdnQqVnN48IwfbnZ2dnUVZ_sWdnZ2d@giganews.com ...
> > 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

>
> check the PHP manual for
>
> mysql_insert_id()
>
>
>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h56.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08762 seconds with 11 queries