•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 374,166 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 3,281 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: 2020 | Replies: 62 | Solved
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
•
•
Join Date: Dec 2007
Posts: 59
Reputation:
Rep Power: 1
Solved Threads: 0
ok fixed it,
Now i have the passwords left...
But i never really understood how i will run the password script you gave me so it inserts the password into each users password field?
So basically i have the table Grads, then i have for each user_id the password field.
hopefully you can give me a hand with this
Never saw how to do this in my book yet.
EDIT: and this is what i fixed
both rows werent showing user_id thats y it wasnt querying it like u said so....
Whats that other thing u told me to change?
I also cant get this welcome script to work not that it really matters but i think its showing me that something isn't right...
and 1 last thing dealing with the security. How am i going to stop people from bypassing the login script and not just going to the survey? or you think cus its only being used by high school students and no one will know the structure it should be fine?
EDIT EDIT:
Also when i do the submit it is only taking the first name for some bizarre reason
Here is the top of the code incase u want it
and this was the exact welcome code....
Now i have the passwords left...
But i never really understood how i will run the password script you gave me so it inserts the password into each users password field?
So basically i have the table Grads, then i have for each user_id the password field.
hopefully you can give me a hand with this
Never saw how to do this in my book yet.
EDIT: and this is what i fixed
$option.="<option value=".$row['user_id'].">".$row['user_id']."</option>";
both rows werent showing user_id thats y it wasnt querying it like u said so....
Whats that other thing u told me to change?
I also cant get this welcome script to work not that it really matters but i think its showing me that something isn't right...
and 1 last thing dealing with the security. How am i going to stop people from bypassing the login script and not just going to the survey? or you think cus its only being used by high school students and no one will know the structure it should be fine?
EDIT EDIT:
Also when i do the submit it is only taking the first name for some bizarre reason
Here is the top of the code incase u want it
<?php
print_r($_POST);
$conn=mysql_connect("********************","*******","**********");
mysql_select_db("gradsurvey");
$query="select user_id from grads";
$result=mysql_query($query);
$option="";
while($row=mysql_fetch_array($result)) {
$option.="<option value=".$row['user_id'].">".$row['user_id']."</option>";
}
if(isset($_POST['submit'])) {
$query="UPDATE TABLE SET VOTE_STATUS = 1 WHERE USER_ID ='".$_POST['user_id']."'";
mysql_query($query);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Etobicoke Collegiate Institute's Grad Survey 2008</title>
</head>
<body>
<?php
// Welcome the user
echo '<h2>Welcome';
if (isset($_SESSION['agent'])) {
echo ", {$_SESSION['agent']}!";
}
echo '</h2>';
// Mail Script
if(isset($_POST['submit'])){
$selection=$_POST['style'];
$a=$_POST['priceisright'];
$b=$_POST['millionaire'];
$c=$_POST['loosepassport'];
$d=$_POST['vanriver'];
$e=$_POST['spusecheat'];
$f=$_POST['marrymoney'];
$g=$_POST['5divorces'];
$h=$_POST['primeminister'];
$i=$_POST['teacheci'];
$j=$_POST['40yearoldvirgin'];
$k=$_POST['livewparents'];
$l=$_POST['dieholdingcell'];
$m=$_POST['damagedliver'];
$n=$_POST['jail'];
$q=$_POST['plasticsurgery'];
$r=$_POST['adoptchildren'];
$s=$_POST['buyfriends'];
$t=$_POST['Dictionary'];
$u=$_POST['guitarhero'];
$v=$_POST['convent'];
$w=$_POST['souljaboywedding'];
$x=$_POST['nobelpeace'];
$y=$_POST['huggerenvironment'];
$z=$_POST['mack'];
$aa=$_POST['ego'];
$ab=$_POST['partier'];
$ac=$_POST['cougar'];
$ad=$_POST['awkward'];
$ae=$_POST['dramtic'];
$af=$_POST['gossip'];
$ag=$_POST['cluts'];
$ah=$_POST['car'];
$ai=$_POST['style'];
$aj=$_POST['hair'];
$ak=$_POST['cutestcouple'];
$al=$_POST['hottestparents'];
$am=$_POST['playboygirl'];
$an=$_POST['kingswaymd'];
$aq=$_POST['funniest'];
$ar=$_POST['athletic'];
$message = "Price is right: $a";
mail("****l@anblickstudios.com","Grad Survey 08",$message,"from: *****@anblickstudios.com");
}
// Mail Script
if(isset($_POST['submit'])){
$selection=$_POST['style'];
$message = "Thank you for registering with our site!\nYour selection was $selection.\n\nSincerely,\nUs";
mail("******@anblickstudios.com","Grad Survey 08",$message,"from: *******@anblickstudios.com");
}
?>and this was the exact welcome code....
<?php
// Welcome the user
echo '<h2>Welcome';
if (isset($_SESSION['agent'])) {
echo ", {$_SESSION['agent']}!";
}
echo '</h2>';
Last edited by dani190 : Jan 17th, 2008 at 9:19 pm.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
Earlier in your query, you were using $row['grad'] as value. So I asked you to change the query. Since you have changed the value to $row['user_id'] it should work fine. Its passing first name because (I think) you are storing first name in user_id column. Because, when I asked you to show what's in <option value=''>..</option>, it showed me the first name.
That doesnt work since you are not setting $_SESSION['agent'] anywhere. First check if $_SESSION['agent'] is not set. If its not set, set agent name. Then this will work.
And about the password generation. Well, the link that I gave you was a function. You just have to copy that function in your script and call that function whenever you want to generate a new password. And this is how you call that function.
php Syntax (Toggle Plain Text)
<?php // Welcome the user echo '<h2>Welcome'; if (isset($_SESSION['agent'])) { echo ", {$_SESSION['agent']}!"; } echo '</h2>';
And about the password generation. Well, the link that I gave you was a function. You just have to copy that function in your script and call that function whenever you want to generate a new password. And this is how you call that function.
php Syntax (Toggle Plain Text)
$pass=generatePassword($length); //length of the password.. by default it takes 8 if you don't specify any.
Last edited by nav33n : Jan 17th, 2008 at 11:13 pm.
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*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
php Syntax (Toggle Plain Text)
$query="select user_id from table"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $x=generatePassword($length); $userid=$row['user_id']; $sql="update table set password='$x' where user_id='$user_id'"; mysql_query($sql); }
Simple. Last edited by nav33n : Jan 18th, 2008 at 1:12 am.
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*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 59
Reputation:
Rep Power: 1
Solved Threads: 0
Ok here is what i have now...
So now this is what i get... Array ( )
Thats all and nothing gets into the database.
Any ideas?
<?php
print_r($_POST);
$conn=mysql_connect("i**********","*************","***********");
mysql_select_db("db33717_gradsurvey");
$query="select password from grads";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
$x=generatePassword($length);
$userid=$row['user_id'];
$sql="update table set password='$x' where user_id='$user_id'";
mysql_query($sql);
}
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++;
}
}
$pass=generatePassword($length); //length of the password.. by default it takes 8 if you don't specify any.
// done!
return $password;
}
?>So now this is what i get... Array ( )
Thats all and nothing gets into the database.
Any ideas?
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
remove print_r($_POST); and then debug yourself. I think I have helped you enough and you are in a state where you can solve your bugs.
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*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
Nope. print_r($_POST); is for debugging. I asked you to remove it because, once your code is up and running, you dont need those debug information. But anyway, unless you dont debug your code yourself, you wont learn anything. Spoon feeding is not good either. So good luck!
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*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,042
Reputation:
Rep Power: 8
Solved Threads: 227
I guess you dont know how a function works ! Am I correct ? The function call should be outside the function and not within itself. It will enter an infinite loop.
should be outside. And it should be something like
I hope here on, you will debug on your own.
$pass=generatePassword($length);
should be outside. And it should be something like
$x=generatePassword(8);I hope here on, you will debug on your own.
Last edited by nav33n : Jan 18th, 2008 at 7:55 pm.
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*
*PM asking for help will be ignored*
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
bcsd bcsm blog blogging ccie certification cheating cisco cissp community competition comptia crime daniweb database defender design desktop gentoo google hacker home ipod linux magazine microsoft navigation networks news opinion php red hat research rhce salary school security social spam spyware sql survey teleworking theft virtual vista web windows work
Other Threads in the PHP Forum
- Previous Thread: My sql image links in table
- Next Thread: parse error, unexpected '<' in /data/www/tppine/camo/data/data.php



Linear Mode