Jump to content

Archived

This topic is now archived and is closed to further replies.

gfmaking

PHP from help

Recommended Posts

ohhh please can any one help me what is wrong with my code here? I use hTML Form with
<form method="post" action="action.php">

I saved the following code in action.php file. When submiting the form blank page apears no data inserted. Please some one help me I have a deadline.

God bless.


<?
$username="gfm";
$password="cris";
$database="Order_db";
$host="localhost";

$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zip'];
$Country=$_POST['Country'];
$Phone=$_POST['Phone'];
$E-Mail=$_POST['E-Mail'];
$Product_01=$_POST['Product01'];
$Product_02=$_POST['Product02'];

$connection = mysql_connect($host,$username,$password)or die( "Unable to connect to server");
$db= mysql_select_db($database,$connection) or die( "Unable to select database");

$query = "INSERT INTO Order_Form VALUES
($First_Name,$Last_Name,$Address,$City,$State,$Zip,$Country,$phone,$E-mail,$email,$Product01,$Product02);
$result = mysql_query($query) or die("Error: ". mysql_error(). " with
query ". $query); // see the problem

if($result) {
echo "Thank You For your Order";
}

mysql_close();
?>

Share this post


Link to post
Share on other sites
so... what's the error?

well i can tell you right now, whatever error you have, here's an error:
[code]
$query = "INSERT INTO Order_Form VALUES
($First_Name,$Last_Name,$Address,$City,$State,$Zip,$Country,$phone,$E-mail,$email,$Product01,$Product02);
[/code]
needs to be (for example. you need to change it to match your column names):
[code]
$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address) VALUES ('$First_Name','$Last_Name','$Address')";
[/code]
you need to have one for one: one column name for one value. I just used the first 3 as an example so i wouldn't have to type it all out. Also, notice the ' ' around the variables (but not the column names)

Share this post


Link to post
Share on other sites
Thanks for your time sir,

I have made the following change but still showing that blank page....



<?
$username="gfm";
$password="chris";
$database="Order_db";
$host="localhost";

$First_Name=$_POST['First_Name'];
$Last_Name=$_POST['Last_Name'];
$Address=$_POST['Address'];
$City=$_POST['City'];
$State=$_POST['State'];
$Zip=$_POST['Zip'];
$Country=$_POST['Country'];
$Phone=$_POST['Phone'];
$E-Mail=$_POST['E-Mail'];
$Product_01=$_POST['Product01'];
$Product_02=$_POST['Product02'];

$connection = mysql_connect($host,$username,$password)or die( "Unable to connect to server");
$db= mysql_select_db($database,$connection) or die( "Unable to select database");

$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address, City, State, Zip, Country, phone, E-mail, Product01, Product02) VALUES
('$First_Name','$Last_Name','$Address','$City','$State','$Zip','$Country','$phone','$E-mail','$Product01','$Product02')";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with
query ". $query); // see the problem

if($result) {
echo "Thank You For your Order";
}

mysql_close();
?>

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.