Hi, I was wondering if someone could look over my coding? x3 I'm really, really new to PHP (just learning, in fact) and a friend gave me this sample code, but it doesn't seem to work... could someone please help? Thank you so much. <3 Here is the full code:
<?php
include ('connect.php');
?>
<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>
<?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']);
?>
<?php
//Make sure the name form is filled out.
if ((isset($_POST['dogname']))
|| ($_POST['dogname'] == "))
die("Oops! You forgot to fill in the name!");
?>
<?php
$ownerid = $_SESSION['id']
?>
<?php
if ((!isset($_POST['Buy Dog']))
{
echo "Congratulations! You've purchased a dog.";
}
else
{
echo "Congratulations! You've purchased a dog.";}
}
?>
<?php
$dog = @mysql_query("INSERT INTO dogs (ownerid, dogname, dogbreed, doggender)
VALUES ('$ownerid', '$dogname', '$doggender')") or die("Error:
".mysql_error());
?>