Code Check Please

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Code Check Please

Post by AliasBDI »

I have a problem with this code, but I am receiving no error:

Code: Select all

$result = mysql_query("SELECT first_name, last_name, email_address, username, decrypted_password, dl, birth FROM users WHERE dl='$dl' AND birth='$birth' ") or die (mysql_error());
if (!$result) {
    print "ERROR - browse query failed.";
    exit();
}
while ( $row = mysql_fetch_array($result) )
{
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

care to clarify on the problem then?
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

???

Post by AliasBDI »

I don't know the problem. I assume the code has an error somewhere. It stops at this part of the code and displays a blank page when called. Here is the full page:

Code: Select all

<?php

include '../includes/db.php';

// Define post fields into simple variables.  These are called CONSTANTS.
$dl = $_POST&#1111;'dl'];
$birth = $_POST&#1111;'birth'];

/* Lets strip some slashes in case the user entered
any escaped characters. */
$dl = stripslashes($dl);
$birth = stripslashes($birth);

/* Do some error checking on the form posted fields */

if((!$dl) || (!$birth))&#123;
header('Location: forgot2.php');
	/*echo 'You did not submit the following required information! <br />';
	if(!$dl)&#123;
		echo "Drivers License is a required field. Please enter it below.<br />";
	&#125;
	if(!$birth)&#123;
		echo "Birth Date is a required field. Please enter it below.<br />";
	&#125;

	include 'forgot.php'; // Show the form again!
	/* End the error checking and if everything is ok, we'll move on to
	 creating the user account */
	exit(); // if the error checking has failed, we'll exit the script! */
&#125;

// Find record in database.
$result = mysql_query("SELECT first_name, last_name, email_address, username, decrypted_password, dl, birth FROM users WHERE dl='$dl' AND birth='$birth' ") or die (mysql_error());
if (!$result) &#123;
    print "ERROR - browse query failed.";
    exit();
&#125;
while ( $row = mysql_fetch_array($result) )
&#123;
$username = $row&#1111;'username'];
$password = $row&#1111;'decrypted_password'];
$first = $row&#1111;'first_name'];
$last = $row&#1111;'last_name'];
$last = $row&#1111;'email_address'];

$activatepath = "/students/login.php";

	
// Let's mail the user!
$subject = "USERNAME and PASSWORD request at $sitename";
$message = "Dear $first $last,

You or someone posing to be you requested that a copy of your USERNAME and PASSWORD to be sent to this email address.

Please disregard this email if you did not request it.  However, if you do wish to login to your BLASTER account, click on the following link (or copy/paste it into your browser address bar):
$sitepath$activatepath

Your information for login is stated below:
	Username: $username
	Password: $password

**Please keep this username and password in a location that is easily accessible by you.

Thanks!
$sitename
http://www.ticketblasters.com
bs:281.457.6700


This is an automated response, please do not reply!";

mail($email, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion());
header('Location: _success_forget.php');
//echo $email;
&#125;

?>
User avatar
Saethyr
Forum Contributor
Posts: 182
Joined: Thu Sep 25, 2003 9:21 am
Location: Wichita, Kansas USA
Contact:

Post by Saethyr »

no changes, just making easier to look at.

Code: Select all

<?php


include '../includes/db.php'; 

// Define post fields into simple variables.  These are called CONSTANTS. 
$dl = $_POST['dl']; 
$birth = $_POST['birth']; 

/* Lets strip some slashes in case the user entered 
any escaped characters. */ 
$dl = stripslashes($dl); 
$birth = stripslashes($birth); 

/* Do some error checking on the form posted fields */ 

if((!$dl) || (!$birth)){ 
header('Location: forgot2.php'); 
   /*echo 'You did not submit the following required information! <br />'; 
   if(!$dl){ 
      echo "Drivers License is a required field. Please enter it below.<br />"; 
   } 
   if(!$birth){ 
      echo "Birth Date is a required field. Please enter it below.<br />"; 
   } 

   include 'forgot.php'; // Show the form again! 
   /* End the error checking and if everything is ok, we'll move on to 
    creating the user account */ 
   exit(); // if the error checking has failed, we'll exit the script! */ 
} 

// Find record in database. 
$result = mysql_query("SELECT first_name, last_name, email_address, username, decrypted_password, dl, birth FROM users WHERE dl='$dl' AND birth='$birth' ") or die (mysql_error()); 
if (!$result) { 
    print "ERROR - browse query failed."; 
    exit(); 
} 
while ( $row = mysql_fetch_array($result) ) 
{ 
$username = $row['username']; 
$password = $row['decrypted_password']; 
$first = $row['first_name']; 
$last = $row['last_name']; 
$last = $row['email_address']; 

$activatepath = "/students/login.php"; 

    
// Let's mail the user! 
$subject = "USERNAME and PASSWORD request at $sitename"; 
$message = "Dear $first $last, 

You or someone posing to be you requested that a copy of your USERNAME and PASSWORD to be sent to this email address. 

Please disregard this email if you did not request it.  However, if you do wish to login to your BLASTER account, click on the following link (or copy/paste it into your browser address bar): 
$sitepath$activatepath 

Your information for login is stated below: 
   Username: $username 
   Password: $password 

**Please keep this username and password in a location that is easily accessible by you. 

Thanks! 
$sitename 
http://www.ticketblasters.com 
bs:281.457.6700 


This is an automated response, please do not reply!"; 

mail($email, $subject, $message, "From: $sitename <$adminemail>\nX-Mailer: PHP/" . phpversion()); 
header('Location: _success_forget.php'); 
//echo $email; 
} 


?>
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

let me reitterate what I meant.

You say the page is displaying blank. Well, this page isn't echoing anything out to be posted to the page, so the page will be blank..

Or do you mean the email is blank? or the email isn't being sent at all?

in other words, what was you expecting to happen?
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

$email is not defined change

Code: Select all

<?php
$last = $row['email_address']; 
?>
to

Code: Select all

<?php
$email = $row['email_address']; 
?>
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

Sorry...

Post by AliasBDI »

The email is not being generated. Nor is the page redirecting (as the header states). So the page is blank. I did some testing on the page to show me where the code was stopping, and that is the code I posted originally.

Sorry about the mix up.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

What is the error levels set as? If they are off (or to low) you might want to consider bumping them up so that any error messages that are supressed gets visible to you.
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

JAM

Post by AliasBDI »

I'm not familiar with setting error levels...
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

I don't think you have an error, check my posting on changing your line of code and let me know what you think.
User avatar
mrvanjohnson
Forum Contributor
Posts: 137
Joined: Wed May 28, 2003 11:38 am
Location: San Diego, CA

Post by mrvanjohnson »

For the record, you would change you Error Level reporting in your php.ini file. I believe you can also set it in the script using the [php_man]error_reporting() [/php_man]function
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Checking it:

Code: Select all

echo 'Error Level: '.(ini_get('error_reporting') == '2047' ? 'E_ALL' : 'Not E_ALL')."\n";
If it's not E_ALL;
Setting it:

Code: Select all

ini_set ('error_reporting', E_ALL);
(added on top of the page)

mrvanjohnson might be very right, just thought it was worth mentioning.
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

mrvanjohnson

Post by AliasBDI »

I must have missed your post. I corrected it. That was definitely a mess up. However, it did not resolve the problem. It is still acting the same.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

have you setup access to the sendmail binary on your system ? or are you using some other type of mail program?

also, have you looked at http://www.php.net/mail ?
AliasBDI
Forum Contributor
Posts: 286
Joined: Fri Nov 15, 2002 10:35 am
Location: Spring, TX, USA

infolock

Post by AliasBDI »

I actually have another page running a similar script that emails new users who create accounts in order that they be confirmed. So email is working.
Post Reply