473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

I need help with having one form's results on one page for multiple answers.

Countess Rayne
I am really new to php, but I want to help my husband have a site where his football friends fill out a form and that form posts all their results on one page. I have the form and the results page, but I can't get each person's results on the same page. Here's the site:

http://twilight-angel.net/vikings
Click on NFL Pool Picks to see what I'm talking about. Here's the code I am using for the top part:

<form action="form_process.php" method="post">
Name: <input type="text" name="name" /><br />
Email: <input type="text" name="email" /><br />
Week One Game One: <br />
<select multiple name="gameone">
<option value="washington">Washington Redskins</option>
<option value="minnesota">Minnesota</option>
</select><br />
<input type="submit" name="submit" value="Submit Data"/>
</form>

And here is my results page:

<form action="form_process.php" method="post">
Name: <?php echo $_POST["name"]; ?><br />
Email: <?php echo $_POST["email"]; ?> <br />
Game One Pick: <?php echo $_POST["gameone"]; ?><br />
<?php
echo "Submitted at ".date("m/d/Y : H:i:s A", time()); ?>


</form></br>

I'd really appreciate any help! Thank you.
Jan 9 '08 #1
11 1576
Markus
6,050 Expert 4TB
So, you want every persons choice to be displayed? You'd need to use a database for that!

If you're able to use MySQL and set up a database on your server, i'd be happy to help. :)

Sorry if i didn't understand your question
Jan 9 '08 #2
So, you want every persons choice to be displayed? You'd need to use a database for that!

If you're able to use MySQL and set up a database on your server, i'd be happy to help. :)

Sorry if i didn't understand your question
I'm still kind of new to MySQL too, but yeah, I do have access to it. I created a database. Now what do I need to do? Please try to be a little patient with me. XD I'm a fast learner sometimes, but I get confused easily. ;) Thank you for helping me!!
Jan 9 '08 #3
Markus
6,050 Expert 4TB
I'm still kind of new to MySQL too, but yeah, I do have access to it. I created a database. Now what do I need to do? Please try to be a little patient with me. XD I'm a fast learner sometimes, but I get confused easily. ;) Thank you for helping me!!
Don't worry about it! Everyone's been where you are now.

Let me refresh my memory on what you want doing...
10 mins!
Jan 9 '08 #4
Markus
6,050 Expert 4TB
Ok

we need to create a table in the database! We'll do that first.

Create a file: createTable.php
in that file:
[php]
<?php
mysql_connect("__server__", "__username__", "__pass__") or die("Error: ".mysql_error());
echo "mysql connected";
mysql_select_db("__name_of_db__") or die("Error: ".mysql_error());
echo "database selected";

// substitute the above credentials with your own!

$query = "CREATE TABLE `zones` (
`id` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 150 ) NOT NULL,
`email` VARCHAR( 150 ) NOT NULL,
`game_one` VARCHAR( 150 ) NOT NULL,
PRIMARY KEY ( `zid` )
)";
mysql_query($query) or die("Error: ".mysql_error()); // create the table
echo "Table created!";
?>
[/php]
Let me know how you get on wityh this part.
Jan 9 '08 #5
Ok

we need to create a table in the database! We'll do that first.

Create a file: createTable.php
in that file:
[php]
<?php
mysql_connect("__server__", "__username__", "__pass__") or die("Error: ".mysql_error());
echo "mysql connected";
mysql_select_db("__name_of_db__") or die("Error: ".mysql_error());
echo "database selected";

// substitute the above credentials with your own!

$query = "CREATE TABLE `zones` (
`id` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 150 ) NOT NULL,
`email` VARCHAR( 150 ) NOT NULL,
`game_one` VARCHAR( 150 ) NOT NULL,
PRIMARY KEY ( `zid` )
)";
mysql_query($query) or die("Error: ".mysql_error()); // create the table
echo "Table created!";
?>
[/php]
Let me know how you get on wityh this part.
Ok. It says "mysql connecteddatabase selectedError: Key column 'zid' doesn't exist in table". Is that ok?
Jan 9 '08 #6
Markus
6,050 Expert 4TB
[php]
$query = "CREATE TABLE `zones` (
`id` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR( 150 ) NOT NULL,
`email` VARCHAR( 150 ) NOT NULL,
`game_one` VARCHAR( 150 ) NOT NULL,
PRIMARY KEY ( `id` )
)";
mysql_query($query) or die("Error: ".mysql_error()); // create the table
echo "Table created!";
?>
[/php]

Frik, im such an idiot sometimes!

Shall worketh now!



















Hopefully..
Jan 9 '08 #7
All right. That seemed to work. It says that the table is created. Next? :D
Jan 10 '08 #8
Markus
6,050 Expert 4TB
Ok, so now we need to INSERT the values passed from the form into the database.

On the page that you're taken to after you select 'submit data' we're going to want to add this:

[php]
<?php
// connect to mysql and select the database!
/*
Stuff here to catch the input
I.E. $_POST[input_name];
You need to make the data safe though (mysql injection)!
Read and learn how to prevent it here
http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php
*/

$query = "
INSERT INTO
`insert_table_name_here`
(name, email, game_one)
VALUES
('$name', '$email', '$game_one')";

$insert = mysql_query($query) or die(mysql_error());
if($insert){
echo "Inserted into table successfully";
} else {
echo "Markus did something wrong!";
}
[/php]
Jan 10 '08 #9
All right. I got that part. :) Next?
Jan 10 '08 #10
Markus
6,050 Expert 4TB
Now we want to get the data from the table!

[php]
// connection stuff!

$query = "SELECT * FROM `table_name_here`";
while($__row = mysql_fetch_array($query){
echo $__row['username_row']." - ".$__row['game_one_row']."<br />";
}
[/php]

from there you should be able to manipulate it to display how you want.

Remember to change: username_row and game_one_row to the correct row names!
Jan 10 '08 #11
When I get to the main end, the last thing you posted, and add it, everything stops working all together. If I can catch you on MSN messanger tomorrow, I might be able to understand more clearly.

My grandmother just died, so that's the reason I haven't been online a whole lot. Coding or graphics seem to keep me from crying, so I'm throwing myself headfirst into this.

Anyways, I hope I'm not too annoying to you. I really appreciate all your help so far!
Jan 11 '08 #12

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

Similar topics

5
by: leegold2 | last post by:
Probably a newbie question about "state": My problem is I have a search form, so user enters a keyword <enter>, then this form posts to another page were the result are displayed. But this...
11
by: Jim | last post by:
Hi, I keep getting form results emailed to me that would indicate a form from my web site is getting submitted with all fields blank or empty, but my code should preventing users from proceeding...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
6
by: kenshiro | last post by:
Hi All, I'm having a problem with some VBA code in one of my Access 2003 databases. I'm getting the following error when running code behind a command button on a form: "Item not found in this...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
0
by: Luongo | last post by:
Hi, I'm working on a mysql-based survey program. On the user page I display the survey form, and on the admin page I display the results for each question. The problem, which I find puzzling, is...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
2
by: Gina G | last post by:
A section of my database stores results from survey forms. Most questions are answered yes or no. For these we have used check-boxes and that works fine. The results for most forms are yes with...
2
by: swethak | last post by:
hi , i write the code in .htm file. It is in cgi-bin/searches/one.htm.In that i write a form submitting and validations.But validations are not worked in that .htm file. I used the same code in my...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.