Development Tutorials
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsCommunityDevelopment Tutorials

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 5th, 2003, 04:04 PM
vanesy vanesy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 vanesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
help please

Hi i have followed the tutorial creating a membership and i'm having trouble. When i enter my info into the join form i get the following

Notice: Undefined variable: pass in C:\website\register.php on line 70

Your membership information has been mailed to your email address! Please check it and follow the directions!

I have globals off.

Here is the full script
<?

include 'db.php';

$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$info = $_POST['info'];


$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$info = stripslashes($info);


if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
}
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
}
include 'join_form.html'; // 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!
}


$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");

$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);

if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been used by another member in our database. Please choose a different Username!<br />";
unset($username);
}
include 'join_form.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}



function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}

$random_password = makeRandomPassword();

$db_password = md5($random_password);

// Enter info into the Database.
$info2 = htmlspecialchars($info);
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, info, signup_date)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$db_password', '$info2', now())") or die (mysql_error());

if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Your Membership at MyWebsite!";
$message = "Dear $first_name $last_name,
Thank you for registering at our website, URL!

You are two steps away from logging in and accessing our exclusive members area.

To activate your membership, please click here: URL$userid&code=$db_password

Once you activate your memebership, you will be able to login with the following information:
Username: $username
Password: $random_password

Thanks!
The Webmaster

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

mail($email_address, $subject, $message, "From: FuzionRadio Webmaster<dj.vanes@ntlbusiness.com>\nX-Mailer: PHP/" . phpversion());
echo 'Your membership information has been mailed to your email address! Please check it and follow the directions!';
}

?>

Reply With Quote
  #2  
Old November 5th, 2003, 07:15 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
I've been looking over the code, and it seems as though you have a couple of extra braces (it might just be 1, but I'll have to double-check).

PHP Code:
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
echo 
'You did not submit the following required information! <br />';
if(!
$first_name){
echo 
"First Name is a required field. Please enter it below.<br />";
}
if(!
$last_name){
echo 
"Last Name is a required field. Please enter it below.<br />";
}
if(!
$email_address){
echo 
"Email Address is a required field. Please enter it below.<br />";
}
if(!
$username){
echo 
"Desired Username is a required field. Please enter it below.<br />";
}
include 
'join_form.html'// 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!
[b]}[/b


I'm not sure where the matching brace for that is... That could be a causing problem.
__________________
____________________________________________
Developer Shed Weekly Writer | DevArticles Forum Moderator
Build Your Own KlipFolio Klip With PHP
FrankManno.com - Under Construction
Design Interactive Group - Under Construction

Reply With Quote
  #3  
Old November 6th, 2003, 02:03 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
In the following function:
Quote:
function makeRandomPassword() {
$salt = "abchefghjkmnpqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
while ($i <= 7) {
$num = rand() % 33;
$tmp = substr($salt, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
You have used the variable $pass, when it has not yet been defined.
PHP Code:
 $pass $pass $tmp
should be
PHP Code:
 $pass "";
$pass .= $tmp
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #4  
Old November 6th, 2003, 08:06 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to dhouston
That's what I was thinking too, laidbak, but PHP isn't strictly typed and doesn't typically require predeclaration of variables, so I ruled it out. Or maybe it's just that this is a log level issue and that most people don't see notices about undeclared variables because the log level's set higher than vanesy's.

Reply With Quote
  #5  
Old November 6th, 2003, 08:31 AM
vanesy vanesy is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 vanesy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Brilliant it works thanks you guys

Reply With Quote
  #6  
Old November 6th, 2003, 10:48 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
dhouston, yes, you would have been correct had you stated exactly that.

It is indeed a WARNING that is only issued to the screen due to the error log level.

It is good to show all Warnings while debugging... makes for more error free code.

Browser output can be turned off and this information can be sent to a text file.

Reply With Quote
  #7  
Old November 6th, 2003, 06:45 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
Quote:
Originally posted by laidbak
In the following function: You have used the variable $pass, when it has not yet been defined.
PHP Code:
 $pass $pass $tmp
should be
PHP Code:
 $pass "";
$pass .= $tmp


Laidbak,

Wouldn't that keep resetting the value of $pass on each iteration? It would be better to declare $pass outside of the loop, or am I wrong in seeing it that way?

Reply With Quote
  #8  
Old November 6th, 2003, 07:14 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Yes, I assumed he would put the first line outside of the loop...
Its probably bad of me to have assumed such.

Reply With Quote
  #9  
Old January 12th, 2004, 02:18 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi all,

I'm having about the same problem. I'm using the same code from the same tutorial. I don't get any error messages, but starting with the characters "

0) || ($username_check > 0)){ echo "Please fix the following errors:
"; if($email_check > 0){ echo "Your email address

" the whole script shows up on the webpage instead of acting like a script. I've tried everything you said in here, to the best of my ability, but no matter what I do the script breaks into normal text at exactly that point. " 0)"

All I know about PHP is what I've taught myself over the last two weeks out of necessity. All things considered, I think I'm doing okay, except that I can't crack this one and I really, really need to.

If this sample code is bogus, then can someone point me to a user permissions tutorial w/ code that actually works?

Can anyone help me in very simple terms? I still have a lot to learn, but no time for that luxury.

Thanks,

Yarrielle

Reply With Quote
  #10  
Old January 12th, 2004, 04:04 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Go ahead and post your code, however, please keep in mind the rules of the board before doing so.

Reply With Quote
  #11  
Old January 12th, 2004, 04:22 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I did read all of the forum rules, and I'm going to try to uphold to them. Just please understand that if I biff up, it's my ignorance and not intentional.

The code is for a user registration form. This entire block is very long, so I'll just post the middle section:

PHP Code:
 $sql_email_check mysql_query("SELECT email_address FROM users 
WHERE email_address='$email_address'"
);
$sql_username_check mysql_query("SELECT username FROM users 
WHERE username='$username'"
); 
$email_check mysql_num_rows($sql_email_check); 
$username_check mysql_num_rows($sql_username_check); 
if((
$email_check 0) || ($username_check 0)){ 
echo 
"Please fix the following errors: <br />"
if(
$email_check 0){ 
echo 
"<strong>Your email address has already been used by another member 
in our database. Please submit a different Email address!<br />"

unset(
$email_address); 



When I view this page, all I see in the browser is
Quote:
0) || ($username_check > 0)){ echo "Please fix the following errors:


Except the entire rest of the form is there, too. Nothing before it shows up. I'm positive that I can teach myself how to change the variables if I can just get these snippets to work correctly in the first place. (I guess this part of the code is the validator.)

I hope I did that correctly!

Thanks,

Yarrielle

Reply With Quote
  #12  
Old January 12th, 2004, 04:33 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Try adding another } after the last line you posted.

Reply With Quote
  #13  
Old January 12th, 2004, 04:51 PM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to dhouston
I'd guess you've got a stray "<" somewhere near the top of your code and that for some reason, the code between that and the ">" in the line that's printing is being interpreted as an HTML tag. I'd wager also that you're running on Windows and that this oddity results in part from bugginess on that platform. Just a guess.

Reply With Quote
  #14  
Old January 12th, 2004, 04:54 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, Laidbak, but no go. I tried what I'm sure you meant, then I tried many different variations in case I had it wrong, but nothing worked. The script still breaks into text at the same point. I appreciate your looking, though!

Reply With Quote
  #15  
Old January 12th, 2004, 04:57 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Post the entire script as an attachment

Reply With Quote
  #16  
Old January 12th, 2004, 05:05 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
dHouston, thank you also for replying. I've searched and the only 'naked' < I can find is here:
PHP Code:
 This is an automated responseplease do not reply!"; 
mail($email_address, $subject, $message, 
"
FromMyDomain Webmastern"sales@protected.com>\n 
X-Mailer: PHP/" 
phpversion()); 


It's the < after "Webmaster" but for all I know it's right. You're right, though, I'm working on Windows. I'm user-side only, so I don't have access to the Unix server, which is Apache.

Perhaps I should be going a different route and finding out if there are any GUI or WYSIWYG PHP editors that will work in/with FrontPage?

Sorry to be so confusing,

Yarrielle

Reply With Quote
  #17  
Old January 12th, 2004, 05:10 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here it is in the attachment.

Yarrielle
Attached Files
File Type: txt uspass.txt (4.3 KB, 541 views)

Reply With Quote
  #18  
Old January 12th, 2004, 06:36 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
First thing you should do is add
error_reporting(E_ALL);
to the top of your script

Reply With Quote
  #19  
Old January 12th, 2004, 06:38 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 8
Secondly, you might want to clean up your grossly long if statement:

PHP Code:
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){ echo 'You did not submit the following required information! <br />'; if(!$first_name){ echo "First Name is a required field. Please enter it below.<br />"; } if(!$last_name){ echo "Last Name is a required field. Please enter it below.<br />"; } if(!$email_address){ echo "Email Address is a required field. Please enter it below.<br />"; } if(!$username){ echo "Desired Username is a required field. Please enter it below.<br />"; } include 'join_form.html'// 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! } 


should be more like
PHP Code:
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username)){
  echo 
'You did not submit the following required information! <br />';
  if(!
$first_name){
    echo 
"First Name is a required field. Please enter it below.<br />";
  }
  if(!
$last_name){
    echo 
"Last Name is a required field. Please enter it below.<br />";
  }
  if(!
$email_address){
    echo 
"Email Address is a required field. Please enter it below.<br />";
  }
  if(!
$username){
    echo 
"Desired Username is a required field. Please enter it below.<br />";
  }

  include 
'join_form.html';
  
// 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!


Though it isn't the best validation routine, it should work much better this way.

Reply With Quote
  #20  
Old January 14th, 2004, 10:40 PM
yarrielle yarrielle is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 yarrielle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I just wanted to thank everyone for helping me with this. I never did get it to work, but I found and purchased a program that will do it for me...I think. There was just too much involved that was over my head for me to use your advice properly. I really appreciate your trying to help, and I'll keep studying! Hopefully some day I'll be one of the people in here who helps the newbies. Thanks all for your time and energy on this.

Yarrielle

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsCommunityDevelopment Tutorials > help please


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek