Jump to content

my .html & .php won't talk....HELP


veronika

Recommended Posts

When I submit my .html form to talk to my .php i get awebpage not found error message.  Can someone please look at the script and let me know what is missing/wrong.  I've checked like over and over again and I can't seem to get it.

 

HTML:

 

<HTML>

<HEAD>

<TITLE>Assignment: Lab #8</TITLE>

</HEAD>

<BODY>

<H1>Records added to Estimates</H1>

<FORM METHOD="POST" ACTION="solution08

.php">

<TABLE CELLSPACING = 8 CELLPADDING = 10 >

<TR>

<TD VALIGN = TOP>

<P><strong>BUDGET:</strong><BR>

<INPUT TYPE = "text" NAME = "budget" SIZE=15 MAXLENGTH=15></P>

<TD VALIGN = TOP>

<P><STRONG>CATEGORY (Select One):</STRONG><BR>

<select>

<option>Credit Card</option>

<option>Check</option>

<option>Cash</option>

</select>

</P>

</TD>

</TR>

<TR>

<TD VALIGN = TOP COLSPAN = 2 ALIGN = LEFT>

<P><Strong>DESCRIPTION</strong>:<BR>

<TEXTAREA NAME = "description" COLS=35 ROWS=5 WRAP=virtual></TEXTAREA></P>

<P><INPUT TYPE = "submit" NAME = "submit" VALUE ="Add Record"></P>

</TD>

</TR>

</TABLE>

</FORM>

</BODY>

</HTML>

 

 

.PHP:

 

<?

if ((!$_POST['budget']) || (!$_POST['category']) || (!$_POST['description'])) {

header( "Location: solution08

.html");

exit;

}

$dbhost = 'localhost';

$dbuser = 'spike';

$dbpwd = '9sj7En4';

$conn=mysql_connect($dbhost,$dbuser,$dbpws) or die (mysql_error());

$dbname = 'homebudget';

$table_name = 'estimates';

mysql_select_db($dbname);

$budget = mysql_escape_string (!$_POST['budget']);

$category = mysql_escape_string (!$_POST['category']);

$description = mysql_escape_string (!$_POST['description']);

$sql = "INSERT INTO $table_name

(budget, category, description) VALUES

('$budget', '$category', '$description')";

$result = mysql_query($sql, $connection) or die(mysql_error());

?>

<HTML>

<HEAD>

<TITLE>Assignment: Lab #8</TITLE>

</HEAD>

<BODY>

<H1>Added Record <? echo "$table_name"; ?></H1>

<TABLE CELLSPACING=5 CELLPADDING=5>

<TR>

<TD VALIGN=TOP>

<P><STRONG>Budget:</STRONG><BR>

<? echo "$budget";?></P>

<P><STRONG>Category:</STRONG><BR>

<? echo "$category"; ?></P>

</TD>

<TR>

<TD VALIGN=TOP COLSPAN=2 ALIGN=CENTER>

<P><STRONG>Description:</STRONG><BR>

<? echo stripslashes("$description"); ?></P>

<P><a href = "solution08

.html">Add Another</a></P>

</TD>

</TR>

</TABLE>

</BODY>

</HTML>

 

Link to comment
Share on other sites

I don't know what editor you are using, but where it says this:

 

<FORM METHOD="POST" ACTION="solution08
.php">

 

Is it all on one line like this:

<FORM METHOD="POST" ACTION="solution08.php">

 

Usually when you get a "Page cannot be found" error it usually means that when you submit your form it looks for the solution08.php but it cannot find it.

 

Is it possible for you to post the exact error?

Link to comment
Share on other sites

Yes,

 

<FORM METHOD="POST" ACTION="solution08
.php">

 

If this is on your editor, you have an issue change it to

 

<form method="POST" action="solution08.php">

 

 

 

If your issue continues to occur, please copy and paste the URL in your web-address bar you redirect to when you fill out the HTML form.

Link to comment
Share on other sites

Just to rule some stuff out.

 

I noticed that you don't have any 'name' in the category drop down. Presumably this should be called 'category' based on the process of elimination from your posts. This is triggering the redirect at the beginning of the php page which is also separating the solution08 and .php. Make sure they are put together.

 

Lastly, and this might now be anything but lets rule it out, can you change the html page to .php just to see what happens?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.