User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 361,627 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,193 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1914 | Replies: 62 | Solved
Reply
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #41  
Jan 18th, 2008
well no i dont ok thanks il give it a shot now
Reply With Quote  
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #42  
Jan 18th, 2008
<?php
print_r($_POST);
ini_set('display_errors','1');
$conn=mysql_connect("********************","*******","**************") or die(mysql_error());
mysql_select_db("db33717_gradsurvey") or die(mysql_error());

$query=("SELECT * FROM grads") or die(mysql_error());

$result=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($result)){

$userid=$row['user_id'];
$password=$row['password'];
$sql="update grads set password"or die(mysql_error());
mysql_query($sql) or die(mysql_error());
}

function generatePassword ($length = 8)
{

  // start with a blank password
  $password = "";

  // define possible characters
  $possible = "0123456789bcdfghjkmnpqrstvwxyz"; 
    
  // set up a counter
  $i = 0; 
    
  // add random characters to $password until $length is reached
  while ($i < $length) { 

    // pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    // we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }
  
  // done!
  return $password;

}

$password=generatePassword(8);

?>

<? 
echo $user_id;
echo $password;
?>

I tried for almost an hour and a half and i still cant get it

I got it down to this error now

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Mind helping me? I think i just cant get this line correct

$sql="update grads set password"or die(mysql_error());

Thanks, Dani.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,861
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 205
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: survey for school grads... Another question

  #43  
Jan 19th, 2008
hmm.. Ok..
  1. <?php
  2. $conn=mysql_connect("********************","*******","**************") or die(mysql_error());
  3. mysql_select_db("db33717_gradsurvey") or die(mysql_error());
  4.  
  5.  
  6. function generatePassword ($length = 8)
  7. {
  8.  
  9. // start with a blank password
  10. $password = "";
  11.  
  12. // define possible characters
  13. $possible = "0123456789bcdfghjkmnpqrstvwxyz";
  14.  
  15. // set up a counter
  16. $i = 0;
  17.  
  18. // add random characters to $password until $length is reached
  19. while ($i < $length) {
  20.  
  21. // pick a random character from the possible ones
  22. $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
  23.  
  24. // we don't want this character if it's already in the password
  25. if (!strstr($password, $char)) {
  26. $password .= $char;
  27. $i++;
  28. }
  29.  
  30. }
  31.  
  32. // done!
  33. return $password;
  34.  
  35. }
  36.  
  37. $query=("SELECT * FROM grads") or die(mysql_error());
  38. $result=mysql_query($query) or die(mysql_error());
  39. while($row=mysql_fetch_array($result)){
  40. $userid=$row['user_id'];
  41. $password=generatePassword(8);
  42. $sql="update grads set password='$password' where user_id='$userid'";
  43. mysql_query($sql) or die(mysql_error());
  44. echo $user_id." : ".$password; //remove this if you dont want to see the user id and password on the screen
  45. }
  46. ?>

This will work.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #44  
Jan 19th, 2008
Just i dont see the users. Thats sorta really important as i changed the script to use SHA-1 encryption so it posts the un encrypted version and i need that output.


Why wont it show the users? Looks fine to me...
Reply With Quote  
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #45  
Jan 19th, 2008
nevermind i got it, ended up being on the echo statement it had to be userid instead of user_id

Thanks a million
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,861
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 205
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: survey for school grads... Another question

  #46  
Jan 19th, 2008
You are welcome!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #47  
Jan 20th, 2008
1 more thing i never got working was that welcome script. How do i save their name from the login script and pass it to the vote page? I now realize i need that as i need to know the person who's voting...

I tried the session but i think i uses the wrong format i am not sure
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,861
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 205
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: survey for school grads... Another question

  #48  
Jan 20th, 2008
When the user logs in, start the session, add his name to a session variable.
Eg.
  1. <?php //page1.php
  2. session_start();
  3. $_SESSION['name']="testuser"; //user name
  4. ?>
  5.  
  6. <?php //page2.php
  7. session_start();
  8. echo $_SESSION['name']; //prints testuser
  9. ?>
Last edited by nav33n : Jan 20th, 2008 at 12:56 pm. Reason: Forgot session_start() in page2.php :P
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Dec 2007
Posts: 59
Reputation: dani190 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

  #49  
Jan 20th, 2008
ya thanks just learned that from this book.

Thanks again.


P.S Seems i am learning
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 2,861
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 7
Solved Threads: 205
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Maven

Re: survey for school grads... Another question

  #50  
Jan 20th, 2008
Great! Read more, Learn more!
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 6:38 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC