Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

form help

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

form help

Postby kat » Tue Nov 26, 2002 11:27 am

I am trying to make a php form that inserts data into a mysql database. THe problem is that there is a record that gets put into the database but it is blank everytime.
here is the code:

<html>

<body>

<form method="post" action="conf.php">

First name:<input type="Text" name="First_Name"><br>

Last name:<input type="Text" name="Last_Name"><br>

Address:<input type="Text" name="How_Many"><br>

Position:<input type="Text" name="Children"><br>

Yes or No:<input type="Text" name="Y_N"><br>

Area Code:<input type="Text" name="Area_Code"><br>

Prefix:<input type="Text" name="Prefix"><br>

Number:<input type="Text" name="Number"><br>

<input type="Submit" name="submit" value="Enter information">

</form>
</body>
</html>


conf.php looks like this:
<?php

$First_Name = $_Post['First_Name'];
$Last_Name = $_Post['Last_Name'];
$How_Many = $_Post['How_Many'];
$Children = $_Post['Children'];
$Y_N = $_Post['Y_N'];

$Area_Code = $_Post['Area_Code'];
$Prefix = $_Post['Prefix'];
$Number = $_Post['Number'];

$db = mysql_connect("localhost", "root", "mypw");

mysql_select_db("randyrsvp",$db);

$sql = "INSERT INTO rsvp (First_Name, Last_Name, How_Many, Children, Y_N, Area_Code, Prefix, Number)
VALUES ('$First_Name','$Last_Name','$How_many','$Children
', '$Y_N','$Area_Code','$Prefix','$Number')";

$done = mysql_db_query("randyrsvp",$sql);

if ($done != '0')
{
echo "you have inserted a record";
}
else
{
echo"insert failed";
}

?>

Does anyone know why all I get is blank records in my database?

Thanks
kat
New php-forum User
New php-forum User
 
Posts: 3
Joined: Mon Nov 25, 2002 8:14 pm

Postby webwired » Sat Dec 07, 2002 9:57 am

Try this out...
Code: Select all
<?php

$db = mysql_connect("localhost", "root", "mypw");

mysql_select_db("randyrsvp",$db);

$sqlquery = "INSERT INTO rsvp VALUES ('$First_Name','$Last_Name','$How_Many','$Children','$Y_N','$Area_Code','$Prefix','$Number')";
$results = mysql_query($sqlquery);
mysql_close();

$done = mysql_db_query("randyrsvp",$sql);

if ($done != '0')
{
echo "you have inserted a record";
}
else
{
echo"insert failed";
}

?>
User avatar
webwired
New php-forum User
New php-forum User
 
Posts: 26
Joined: Sat Nov 23, 2002 5:20 pm
Location: St. Louis, Missouri


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron