|
Posted by ire.kevin on 10/21/91 11:34
I'm creating a birthday list creator. Using drop down menus for day,
month, and year. I can manually insert data into my table and have it
displayed. But I can't get my forumn to submit the data to the
database.
I have labeled "MySQL Table" , "PHP", and "HTML" below for easy
reading. This is all on one page.
What am I doing wrong?
------------------
MySQL Table
------------------
id int(11) No auto_increment
name text No
day int(2) No 0
month int(2) No 0
year int(4) No 0
------------------
PHP
------------------
<?
mysql_connect("localhost","irekevin_irekevi","k24a2");
mysql_select_db("test");
if($submit)
{
$result=MYSQL_QUERY("INSERT INTO birhtday (id,name,day,month,year)".
"VALUES ('NULL', '$id','$name', '$day', '$month', '$year')");
}
?>
<?
$result = mysql_query("select * from birhtday order by month desc limit
1");
while($r=mysql_fetch_array($result))
{
$name=$r["name"];
$day =$r["day"];
$month=$r["month"];
$year=$r["year"];
?>
<div class="box">
<div class="name"><? echo $name ?></div>
<div class="day"><? echo $day ?></div>
<div class="month"><? echo $month ?></div>
<div class="year"><? echo $year ?></div>
<br />
<br />
</div>
</div>
<? } ?>
------------------
HTML
------------------
<form action="<? echo $php_self ?>" method="post">
<br />
<input id="name" type='text' value='Name' name='name' size="15"
maxlength='100'>
<input type="submit" name="submit" value="Submit"/>
<br />
<select name="day">
<option value="1">01</option>
<option value="2">02</option>
etc...
</select>
<select name="month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
etc....
</select>
<select name="year">
<option value="1970">1970</option>
<option value="1971">1971</option>
etc...
</select>
</form>
Navigation:
[Reply to this message]
|