Jump to content

PHP from help


gfmaking

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();
?>
Link to comment
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)
Link to comment
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();
?>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.