•
•
•
•
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
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
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.
Edit: If you encounter any errors, let me know.
Cheers,
Naveen
php Syntax (Toggle Plain Text)
<?php $conn=mysql_connect("localhost","username","password"); mysql_select_db("student"); $query="select user_id,student_name from student"; $result=mysql_query($query); $option=""; while($row=mysql_fetch_array($result)){ $option.="<option value=".$row['user_id'].">".$row['student_name']."</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 /> </body> </html>
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*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 59
Reputation:
Rep Power: 1
Solved Threads: 0
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
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.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
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*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 59
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
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
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
ok.. That's not a problem! call that handle.php. This will print all the form variables
!
php Syntax (Toggle Plain Text)
<?php print_r($_POST); ?>
! 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,098
Reputation:
Rep Power: 8
Solved Threads: 240
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*
*PM asking for help will be ignored*
•
•
Join Date: Dec 2007
Posts: 59
Reputation:
Rep Power: 1
Solved Threads: 0
well i tried that and all i get is Array ( [priceisright] => )
The code i have now is
and handle.php is
so how would i get this working... as i said i really don't know much about php and mysql
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
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
* 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.
* 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.
php Syntax (Toggle Plain Text)
<?php $conn=mysql_connect("localhost","username","password"); mysql_select_db("dbname"); $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 = 1 WHERE USER_ID ='".$_POST['priceisright']."'"; 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> <form action="vote.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 name="submit" value="submit" type="submit"> </form> </body> </html>
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*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
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
- Previous Thread: Formatting blob fields
- Next Thread: Basic Web App



Linear Mode