Okay im doing a project for my FIRST robotics team where we are getting a scouting database going on where we scout out other teams

I have gotten the basics down but i am having multiple problems with my php code all i need to do is make my submit button work so that the variables that are inputed by the user are saved onto a txt file but if someone could help me output it onto another php page that would be even better. plz help here is my code.

$myFile = "database.txt";
$fh = fopen($myfile,'w') or die("can't open file");
$stringData = "hello/n";

<form method="post" action="<?php echo $PHP_SELF;?>">
Team Number:<input type="text" size="12" maxlength="12" name="Tnumber">:<br />

Special robot features::<br />
Xbox Kinect:<input type="checkbox" value="xbox" name="feature1[]">:<br />
autonomous:<input type="checkbox" value="autonomous" name="feature2[]">:<br />
Please choose where their autonomous period scores::<br />
top:<input type="checkbox" value="top" name="autonomous1[]">:<br />
middle:<input type="checkbox" value="middle" name="autonomous2[]">:<br />
bottom:<input type="checkbox" value="bottom" name="autonomous3[]">:<br />

<textarea rows="5" cols="20" name="comment" wrap="physical">Enter any comments about the team here</textarea>:<br />

<input type="submit" value="submit" name="submit">

} else {

echo "$Tnumber";
echo "$feature1";
echo "$feature2";
echo "$autonomous1";
echo "$autonomous2";
echo "$autonomous3";
echo "$comment";

5 Years
Discussion Span
Last Post by deviantghost

If you want to pass variables to another PHP module, you probably want to use session variables. This is pretty easy. You need a session_start() in every module where you are creating/using the session variables. You can then create a session variable almost like creating a local variable:

$_SESSION["a"] = "xxxxx";

Once i make the session how do i call the variable on the next page and will i be able to use any mathematical code to calculate the average of something?


To use session variable you should do the following, which is based off of the example previously given:

$a = $_SESSION['a'];

It's just like using $_GET and $_POST but PHP will pulled the data out of a user's session when using $_SESSION.

Such as:

$_SESSION['username'] = $username;

You'd use this after someone has logged into your site or created an account to start a session for them which will save their username. Of course you can also add $password and whatever other info you want passed between PHP scripts. Then do the following whenever you want to use their username:

$username = $_SESSION['username'];

Other examples might be if you want visitors to be able to select the font size for the text displayed on your sites you may want to save that info to their session so that as they go from page to page the text will be consistent with the size the selected.

Votes + Comments
well detailed

One quick last question for my webpage no one needs to log in but input comments and check off check boxes I want to be able to calculate the average amoung of times people check off the boxes that I have.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.