hi

i have a html page with a form. you enter information into the form then have a choice of 2 buttons. depending on the button you press you get taken to a different page. the php page commits the data you put into he form to the database then after 5 seconds should take you to the page you want.
I have attached my php code but i get the following 3 errors:


Notice: Undefined index: Add Another Team in C:\wamp\www\addteam.php on line 11

Notice: Undefined index: Finish Adding Teams in C:\wamp\www\addteam.php on line 14

Not Found

The requested URL /<br /><b>Notice</b>: Undefined variable: page in <b>C:\wamp\www\addteam.php</b> on line <b>3</b><br /> was not found on this server.

please can you help me fix this error. I am new to php and cannot figure it out

php code:

<html>
<head>
<META HTTP-EQUIV="refresh" CONTENT="5;URL=<?php echo $page; ?>">
<title>Football League</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>

<?php

if ($_POST['Add Another Team'])
{
$page = addteam.html; }
else if ($_POST['Finish Adding Teams']) {
$page = index.html; }

?>
<div id="contain">
<div id="header">
<div id="logo">
<h1>Football League Database</h1>
</div>

<div id="menu">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<li><a href="addteam.html">Create League/Cup</a></li>
<li><a href="statistics.html">View Statistics</a></li>
<li><a href="fixtures.html">View/Update Fixtures</a></li>
</ul>
</div>
</div>

<div id="page">
<div id="content">
<h1>Your have entered the following details:</h1>
<div class="header">

<?php

//MySQL Database Connect
include 'dblogin.php';

//Retreve data from form
$teamname = "$_POST[teamname]";
$teammanager = "$_POST[teammanager]";

//Insert SQL Statement
$query = "insert into team (name, manager) values (trim('$teamname'), trim('$teammanager'))";

if (!mysql_query($query,$conn))
{
die('Error: ' . mysql_error());
}

echo"
<html>
<table>
<tr>
<td>Team Name: </td>
<td>$teamname</td>
</tr>
<tr>
<td>Team Manager: </td>
<td>$teammanager</td>
</tr>
</table>
</html>
";

print "You will be redirect in 5 seconds<br>";

mysql_close($conn);

?>
</div>
</div>
</div>
</body>
</html>

I am not really sure, but can variables declared with a space? Try to replace "Add Another Team" with "Add_Another_Team" and "Finish Adding Teams" with "Finish_Adding_Teams" and please let me know if that solves the problem.

~Simon

I am not really sure, but can variables declared with a space? Try to replace "Add Another Team" with "Add_Another_Team" and "Finish Adding Teams" with "Finish_Adding_Teams" and please let me know if that solves the problem.

~Simon

Add Another Team and Finish Adding Teams is what it is getting from the form on my html page the variable is called $page

anyone got any ideas how to resolve my issue?

Yeah, I know. But you cannot send variables with a space via HTTP. So replace the names of your HTML-Tags with "_"'s.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.