survey for school grads... Another question

Thread Solved

Join Date: Dec 2007
Posts: 63
Reputation: dani190 is an unknown quantity at this point 
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

survey for school grads... Another question

 
0
  #1
Jan 13th, 2008
Hey Sorry to bug you guys again. I had one more question. As i am developing this program now i realize that i have no clue how to save the data to the database.

basically the whole point in making this program was to be able to export a table in my database that would store all the submitted data from the survey.

I will have like 30 questions and almost 400 grads. all that data needs to be recorded.

What is going to be the easiest table structure to do that type of thing?

Or is e-mail just going to end up being easier?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: survey for school grads... Another question

 
0
  #2
Jan 14th, 2008
  1. CREATE TABLE test (
  2. id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
  3. name VARCHAR( 100 ) NOT NULL ,
  4. address VARCHAR( 100 ) NOT NULL
  5. ) ENGINE = InnoDB
If that's my table, and I have a form with 2 fields name and address, this is how I would be inserting the values to the table test. This should get you started.(I hope!)
  1. <?php
  2. if(isset($_POST['submit'])){
  3. $conn=mysql_connect("localhost","root");
  4. mysql_select_db("exact");
  5. $name=$_POST['name'];
  6. $address=$_POST['address'];
  7. $query="INSERT INTO TEST (ID,NAME,ADDRESS) VALUES ('','$name','$address')";
  8. mysql_query($query);
  9. }
  10. ?>
  11. <html>
  12. <body>
  13. <form method="post" action="insert_example.php">
  14. Enter Name: <input type="text" name="name"><br />
  15. Enter Address: <textarea rows="10" cols="20" name="address"></textarea>
  16. <br />
  17. <input type="submit" name="submit" value="submit">
  18. </form>
  19. </body>
  20. </html>

Cheers,
Nav
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 63
Reputation: dani190 is an unknown quantity at this point 
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

 
0
  #3
Jan 14th, 2008
so if i wanted to send all the results via e-mail i would do something similar? i am going to search on that site you gave me and that book lets see if i can get it....

I found out how to mail it i just need some help with the security now.

I want to stop people from just going to the page vote.php, i want them going through the login how is that done?
Last edited by dani190; Jan 14th, 2008 at 2:35 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: survey for school grads... Another question

 
0
  #4
Jan 14th, 2008
You can use mail function.
Eg.
mail("to address","subject","message contents","from: from address");
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 63
Reputation: dani190 is an unknown quantity at this point 
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

 
0
  #5
Jan 14th, 2008
so i know that part but how do i then integrate it with the submit button? And how do i tell the mail function what to mail... Like what form questions I wasnt able to find out how to do that yet
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: survey for school grads... Another question

 
0
  #6
Jan 14th, 2008
Well, you can have a condition to check if the submit button was pressed.
  1. if(isset($_POST['submit'])){
  2. $message="This is the body of this mail. blah blah blah..........some more text... ";
  3. mail("test@gmail.com","test mail",$message,"from: someone@gmail.com");
  4. }
you can send all the data in the message part of the mail.
Last edited by nav33n; Jan 14th, 2008 at 2:58 pm.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 63
Reputation: dani190 is an unknown quantity at this point 
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

 
0
  #7
Jan 14th, 2008
ok so basically i can wrap that around the whole form were they are entering the info?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: survey for school grads... Another question

 
0
  #8
Jan 15th, 2008
Yep. Get all the form information, align it as you want. Put it in the 'message' part of the mail.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 63
Reputation: dani190 is an unknown quantity at this point 
Solved Threads: 0
dani190 dani190 is offline Offline
Junior Poster in Training

Re: survey for school grads... Another question

 
0
  #9
Jan 16th, 2008
k so 1 more thing

In the email part i dont know how to retrieve the persons answers from the folllowing...

  1. <label>40. Funniest</label><br />
  2. <select name="funniest">
  3. <option value="">Please Choose One Person</option>
  4. <option value="">Not Voting</option>
  5. <?php echo $option; ?>
  6. </select>
  7. <br />

...

Thanks, Dani
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,748
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 331
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: survey for school grads... Another question

 
0
  #10
Jan 16th, 2008
On submitting the page, if the user has selected a value from the select box, it will be in $_POST['funniest']. So, you can do something like $x=$_POST['funniest']. $x will have his selection.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC