Welcome to DaniWeb -- I'm pretty new here myself.
By the way, you can use the [ code][/code] tags to separate out your code snippets.
A couple pointers to start ...
Use curly brackets
{} in your code, even when you can skip them
Use line indentation for successively nested blocks of code
Both of these will help you read your code better and find common problems faster
I found some missing end of line semi-colons (
;). Programming is unforgiving of such minuscule errors.
There is no reason to chop up your PHP code with multiple
<?php ... ?> blocks, unless there is regular html or other plain text in between these blocks.
Your first
!isset test condition was missing the (
!)
Your mysql query was missing
'$dogbreed',
I think that's all I found that looked wrong in this code...but I might have missed something too. ;-)
<?php
include ('connect.php');
?>
<html>
<head>
</head>
<body>
<form name="form1" method="post" action="dogstore.php">
Dog's Name:
<input name="dogname" type="text">
<br>
Dog's Breed:
<select name="dogbreed">
<option value="breed1">Breed</option>
<option value="breed2">Breed</option>
<option value="breed3">Breed</option>
<option value="breed4">Breed</option>
<option value="breed5">Breed</option>
<option value="breed6">Breed</option>
<option value="breed7">Breed</option>
</select>
<br>
Dog's Gender:
<select name="doggender">
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<br>
<input type="submit" name="Submit" value="Buy Dog">
</form>
</body>
</html>
<?php
//trim removes the white spaces from the beginning and end of the text
$dogname = trim( $_POST['dogname'] );
$dogbreed = trim( $_POST['dogbreed'] );
$doggender = trim( $_POST['doggender'] );
//Make sure the name form is filled out.
if ( ( !isset( $_POST['dogname'] ) ) || ( $_POST['dogname'] == '' ) ) { // !
die( "Oops! You forgot to fill in the name!" );
}
$ownerid = $_SESSION['id']; // ;
if ( ( !isset( $_POST['Buy Dog'] ) ) {
echo "Congratulations! You've purchased a dog."; // not really ...
} else {
echo "Congratulations! You've purchased a dog.";
}
$dog = @mysql_query( "INSERT INTO dogs (ownerid, dogname, dogbreed, doggender) VALUES ('$ownerid', '$dogname', '$dogbreed', '$doggender')" ) or die( "Error:".mysql_error() ); //'$dogbreed',
?>
Hope this helps, and keep playing and practicing ...