473,569 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP mysql survey

35 New Member
I must build a survey with many question (around 50), so i cannot have the survey in just one page, i would like to have it on many pages so one user will hit submit many times, how can i make so in the database there's always one Row per user and not many rows as many submit per user?
Nov 16 '09 #1
4 3498
Atli
5,058 Recognized Expert Expert
Hey.

You can use the UPDATE command to do that.
Use INSERT on the first page and just UPDATE the row on the proceeding pages.
Nov 16 '09 #2
arty
35 New Member
hi, yes but the action attribute of the form is another form so it wont complete the MSQL command:
<form method="post" action="Q2.php" >
looks like i need to use sessions so i do all the SQL command on the last form/page
Nov 16 '09 #3
Atli
5,058 Recognized Expert Expert
What do you mean?

You just use a different SQL query on each page...

page1.php
Expand|Select|Wrap|Line Numbers
  1. <form action="page2.php" method="post">
  2.     <input type="text" name="first_info" />
  3.     <input type="submit" />
  4. </form>
  5.  
page2.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Get the data from the last form
  3. $first_info = mysql_real_escape_string($_POST['first_info']);
  4.  
  5. // Insert a new row into the database
  6. $sql = "INSERT INTO tbl(first_info) VALUES('{$first_info}')";
  7. mysql_query($sql) or trigger_error(mysql_error(), U_USER_ERROR);
  8.  
  9. // Get the ID of the row that was just created.
  10. $row_id = mysql_insert_id();
  11. ?>
  12. <form action="page3.php" method="post">
  13.     <input type="hidden" name="row_id" value="<?php echo $row_id; ?>" />
  14.     <input type="text" name="second_info" />
  15.     <input type="submit" />
  16. </form>
  17.  
page3.php
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. // Get the data from the last form
  3. $second_info = mysql_real_escape_string($_POST['second_info']);
  4. $row_id = mysql_real_escape_string($_POST['row_id'])
  5.  
  6. // Update the row in the database with the new info
  7. $sql = "UPDATE tbl 
  8.         SET second_info='{$second_info}' 
  9.         WHERE row_id={$row_id}
  10.         LIMIT 1";
  11. mysql_query($sql) or trigger_error(mysql_error(), U_USER_ERROR);
  12. ?>
  13. <form action="page4.php" method="post">
  14.     <input type="hidden" name="row_id" value="<?php echo $row_id; ?>" />
  15.     <input type="text" name="third_info" />
  16.     <input type="submit" />
  17. </form>
  18.  
etc...
Nov 17 '09 #4
arty
35 New Member
thanks , i have just made something with session,i will check your version.
thanks again.
Nov 17 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5604
by: Paris_Sucks | last post by:
I'm trying to redirect when testing for certain condidtions as shown below. When the conditions are ture, it redirects, but still goes ahead and processes the sql query. What am I doing wrong??? And then sometimes when the conditions are correct, it doens't redirect. It appears to be very inconsistent. Any suggestions would be greatly...
1
5696
by: GTF | last post by:
PHP Web Survey Idea.. I have been given an opportunity to create a web based survey. This is a fairly lengthy survey of 60 pages on paper (various multiple choice and free form). These are the Requirements: -Provide a web interface to a database -Database stores the data (duh), but the capacity to extract the data
2
4434
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a problem with defining my JDBC resource within Tomcat. I am pretty sure that my code is correct (but I am not certain), and the problem is with...
4
4168
by: Mmm_moo_cows | last post by:
Hi, I'm new to the world of mysql and i'm having alot of trouble with it. All i want to do is create a page with a response form, e.g. name etc and some radio buttons (part of a uni project, but i'm a chemist!) and a submit button to save the data in a database. I installed iss microsoft web server and php and the mysql database. Php...
175
11264
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I think is PostgreSQL would have less USP's (Uniqe Selling Points
110
10509
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst case scenario for MyISAM backend? Also is it possible to not to lose data but get them corrupted?
3
2489
by: Miyagi | last post by:
I am running a custom setup that the workgroup here needs to run. IIS6 with Windows Server 2K3. PHP install was a little tricky but only required the Environment Path to include C:\PHP\ and use the php.ini in the PHP dir. The htdocs directory is located on the D:\ I also installed MySQL on the D:\ and have the PATH variable for that as...
1
1930
by: runsun | last post by:
I am new in PHP/Mysql. I want to input sth from website to mysql, then output the formatted data to .txt, and finally use Excel to open the .txt file. I believe there are better and simpler ways than what I did. But I want to know what's wrong in my codes. Here are the details: In survey.html, I need people input their ID and comment. In Mysql,...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.