PDA

View Full Version : mySQL & PHP help


Dan
06-27-2004, 05:40 PM
This is a non-vB related thing but I thought I'd ask here to see if I could get some help.

I have this form I created which is suppose to insert data into fields in a table in my mysql database but it seems not to work and I have no clue why.

Any help would be appreciated!

going.php

<?php
include 'header.htm';
?>
<?php
include 'include.php';
?>
<table width="600" cellpadding="0" cellspacing="0">
<form name="info" action="./index.php" method="post">

<tr>
<td valign="top" width="20%">Name:</td><td width="80%"><input type="text" size="50" name="name" value=""></td>
</tr>

<tr>
<td valign="top" width="20%">Are you staying at the hotel?</td><td width="80%"><input type="text" size="50" name="hotel" value="Yes or No?"></td>
</tr>

<tr>
<td valign="top" width="20%">Are you staying Friday?</td><td width="80%"><input type="text" size="50" name="friday" value="Yes or No?"></td>
</tr>

<tr>
<td valign="top" width="20%">Are you staying Saturday?</td><td width="80%"><input type="text" size="50" name="saturday" value="Yes or No?"></td>
</tr>

<tr>
<td valign="top" width="20%">Are you staying Sunday?</td><td width="80%"><input type="text" size="50" name="sunday" value="Yes or No?"></td>
</tr>

<tr>
<td width="100%" align="right" colspan="2"><input type="submit" name="info" value="Submit"></td>
</tr>
</form>
</table>


<?php
include 'footer.htm';
?>



include.php

<?
mysql_pconnect("localhost","usernameremoved","passwordremoved")
or die("Unable to connect to SQL server");
mysql_select_db("infuse_mudmeet") or die("Unable to select database");
if(isset($_POST[info])){
$F43296slq = mysql_query("INSERT into info values(\"$_POST[name]\", \"$_POST[hotel]\", \"$_POST[friday]\", \"$_POST[saturday]\", \"$_POST[sunday]\" ) ");

}
?>



and this is what the database looks like


CREATE TABLE `info` (
`name` text NOT NULL,
`hotel` text NOT NULL,
`friday` text NOT NULL,
`saturday` text NOT NULL,
`sunday` text NOT NULL
)

assassingod
06-27-2004, 05:42 PM
The form action needs to be include.php

Dan
06-27-2004, 05:52 PM
Hmm... I never had to do that before..... any clue why?

assassingod
06-27-2004, 06:04 PM
Nope, that's just the way I process my forms.