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 427,215 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,142 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: 2270 | Replies: 24 | Solved
Reply
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: trying to make a survey for school yearbook, need help

  #11  
Jan 10th, 2008
I presume that you don't have much knowledge on php. You can go to w3schools and start learning the basics. But anyway, here is the script that you want. Make sure you enter the username and password correctly for your mysql connection,give the correct database name and specify the correct columns in the query.
  1. <?php
  2. $conn=mysql_connect("localhost","username","password");
  3. mysql_select_db("student");
  4. $query="select user_id,student_name from student";
  5. $result=mysql_query($query);
  6. $option="";
  7. while($row=mysql_fetch_array($result)){
  8. $option.="<option value=".$row['user_id'].">".$row['student_name']."</option>";
  9. }
  10. ?>
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  15. <title>Etobicoke Collegiate Institute's Grad Survey 2008</title>
  16. </head>
  17. <body>
  18. <form action="handle.php" method="post">
  19. <fieldset><legend>Please complete the following questions. Thanks!</legend>
  20.  
  21. <label>1. Be on the price is right</label><br />
  22. <select name="priceisright">
  23. <option value="">Please Choose One Person</option>
  24. <option value="">Not Voting</option>
  25. <?php echo $option; ?>
  26. </select>
  27. <br />
  28.  
  29.  
  30. </body>
  31. </html>
  32.  

Edit: If you encounter any errors, let me know.

Cheers,
Naveen
Last edited by nav33n : Jan 10th, 2008 at 11:16 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*
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: trying to make a survey for school yearbook, need help

  #12  
Jan 10th, 2008
omg thats sick, thank you so much.

Now i need to put in the submit buttons and the login page.

So now, if i want to put the submit button, i want it to send back the info and that info would be an ip address using this script http://www.laughing-buddha.net/jon/php/remoteip/,

and i want it to fill in the value vote_status (the table is grads and the row is vote_Status) all i need is a simple change from the current 0 to a 1
so i can see who has voted and who hasn't.

How is that done?

Also if i have all the users and i need the passwords for them before they login, how do i get those generated using that script you showed me....

thanks again

EDIT: I fixed the 1 error i got so don't worry about that
Last edited by dani190 : Jan 10th, 2008 at 11:23 pm.
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: trying to make a survey for school yearbook, need help

  #13  
Jan 10th, 2008
In handle.php just add print_r($_POST); at the top. You will get all the values passed from the form. You can then update your table by setting 1 for that particular person. And, the password generation script is a function. You just call the function, assign the return value to a variable, use that variable. Eg. $pass=functionname();

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: trying to make a survey for school yearbook, need help

  #14  
Jan 10th, 2008
Originally Posted by nav33n View Post
In handle.php just add print_r($_POST); at the top. You will get all the values passed from the form. You can then update your table by setting 1 for that particular person. And, the password generation script is a function. You just call the function, assign the return value to a variable, use that variable. Eg. $pass=functionname();



But i don't have a handle.php yet
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: trying to make a survey for school yearbook, need help

  #15  
Jan 10th, 2008
ok.. That's not a problem!
  1. <?php print_r($_POST); ?>
call that handle.php. This will print all the form variables !
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: trying to make a survey for school yearbook, need help

  #16  
Jan 11th, 2008
will that record the choices and add a 1 to the vote status
?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: trying to make a survey for school yearbook, need help

  #17  
Jan 11th, 2008
Nope. It will show all the form variables that are passed. You can then use it to record the choices.
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: trying to make a survey for school yearbook, need help

  #18  
Jan 11th, 2008
well i tried that and all i get is Array ( [priceisright] => )


The code i have now is

 <?php
$conn=mysql_connect("localhost.anblickstudios.com","bullseye","6cr39a.c"); 
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['grads'].">".$row['user_id']."</option>";    
}
?>
<!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>
<form action="handle.php" method="post">
<fieldset><legend>Please complete the following questions. Thanks!</legend>

<label>1. Be on the price is right</label><br />
<select name="priceisright">
  <option value="">Please Choose One Person</option>
  <option value="">Not Voting</option>
	<?php echo $option; ?>
</select>
<br />
<input type="submit">


</body>
</html>

and handle.php is

<?php 
print_r($_POST); 
?>

so how would i get this working... as i said i really don't know much about php and mysql
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: trying to make a survey for school yearbook, need help

  #19  
Jan 12th, 2008
* Do NOT display the host,username and password while posting in a public forum(Unless you want your database to be hacked!).
* You aren't closing your form.

Anyway, I think you should learn php and mysql first. Here is the script. Name it vote.php and run it. Change table name and the column names.
  1. <?php
  2. $conn=mysql_connect("localhost","username","password");
  3. mysql_select_db("dbname");
  4. $query="select user_id from grads";
  5. $result=mysql_query($query);
  6. $option="";
  7. while($row=mysql_fetch_array($result)) {
  8. $option.="<option value=".$row['user_id'].">".$row['user_id']."</option>";
  9. }
  10. if(isset($_POST['submit'])) {
  11. $query="UPDATE TABLE SET VOTE = 1 WHERE USER_ID ='".$_POST['priceisright']."'";
  12. mysql_query($query);
  13. }
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. <title>Etobicoke Collegiate Institute's Grad Survey 2008</title>
  20. </head>
  21. <body>
  22. <form action="vote.php" method="post">
  23. <fieldset><legend>Please complete the following questions. Thanks!</legend>
  24.  
  25. <label>1. Be on the price is right</label><br />
  26. <select name="priceisright">
  27. <option value="">Please Choose One Person</option>
  28. <option value="">Not Voting</option>
  29. <?php echo $option; ?>
  30. </select>
  31. <br />
  32. <input name="submit" value="submit" type="submit">
  33. </form>
  34. </body>
  35. </html>
  36.  
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: trying to make a survey for school yearbook, need help

  #20  
Jan 12th, 2008
ok, so now that i have that, how do i add in a login page? Basically i just want the person to enter their user_id which is their name, and then i want them to enter their password which i will randomly generate....
Reply With Quote  
Reply

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

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

 

Thread Tools Display Modes

Other Threads in the PHP Forum

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