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,626 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,224 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

survey for school grads... Another question

  #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?
AddThis Social Bookmark Button
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

  #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
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

  #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 1:35 pm.
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

  #4  
Jan 14th, 2008
You can use mail function.
Eg.
mail("to address","subject","message contents","from: from address");
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

  #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  
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

  #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 1:58 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: survey for school grads... Another question

  #7  
Jan 14th, 2008
ok so basically i can wrap that around the whole form were they are entering the info?
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

  #8  
Jan 14th, 2008
Yep. Get all the form information, align it as you want. Put it in the 'message' part of the mail.
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

  #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...

<label>40. Funniest</label><br />
<select name="funniest">
  <option value="">Please Choose One Person</option>
  <option value="">Not Voting</option>
	<?php echo $option; ?>
</select>
<br />

...

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

  #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.
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:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC