The php $_SERVER['PHP_SELF'] form comes up fine, I can
fill it out, but when I click 'submit' I get the
following error:
The requested URL
/php_excercises/{/php_excercises/schedule.php} was not
found on this server.
..and my database table is ignored. This was all
working just fine before and I don't remember changing
anything.
Here is my code:
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Listing 13.1 Opening a Connection to a
Database</title>
</head>
<body>
<?php
if ( ! empty( $_REQUEST['sound'] )&&
! empty( $_REQUEST['equip'] )&&
! empty( $_REQUEST['food'] )&&
! empty( $_REQUEST['drink'] )&&
! empty( $_REQUEST['comp'] ) ){
// check user imput here!
$dberror = "";
$ret = add_to_database( $_REQUEST['sound'],
$_REQUEST['equip'],
$_REQUEST['food'],
$_REQUEST['drink'],
$_REQUEST['comp'], $dberror );
if ( ! $ret ) {
print "Error: $dberror<br />\n";
} else {
print "Thank you very much<br />\n";
}
} else {
write_form();
}
function add_to_database( $sound, $equip, $food,
$drink, $comp, &$dberror ) {
$sound = mysql_real_escape_string( $sound );
$equip = mysql_real_escape_string( $equip );
$food = mysql_real_escape_string( $food );
$drink = mysql_real_escape_string( $drink );
$comp = mysql_real_escape_string( $comp );
$link = mysql_pconnect( "localhost", "", "" );
if ( ! $link ) {
$dberror = mysql_error();
return false;
}
if ( ! mysql_select_db( "schedule05", $link ) ) {
$dberror = mysql_error();
return false;
}
$query = "INSERT INTO specs( sound, equip, food,
drink, comp )
values('$sound', '$equip', '$food', '$drink',
'$comp' )";
if ( ! mysql_query( $query, $link ) ) {
$dberror = mysql_error();
return false;
}
return true;
}
function write_form() {
print '
<form method="post" action="{' .
$_SERVER['PHP_SELF'] . '}">
<p><input type="text" name="sound" />
Does venue have mixer?</p>
<p><input type="text" name="equip" />
Does venue have its own equipment?</p>
<p><input type="text" name="food" />
What kind of food deal?</p>
<p><input type="text" name="drink" />
What kind of drink deal?</p>
<p><input type="text" name="comp" />
What is our compensation?</p>
<p><input type="submit" value="submit!" /></p>
</form>
</FORM> ';
}
?>
</form>
</BODY>
</HTML>
=====
Patrick Roane
Web design and development
www.franklin-band.com
Fox River Grove, Il.
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php