Jump to content


Photo

PHP from help


  • Please log in to reply
2 replies to this topic

#1 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 June 2006 - 07:07 AM

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();
?>


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 23 June 2006 - 07:17 AM

so... what's the error?

well i can tell you right now, whatever error you have, here's an error:
$query = "INSERT INTO Order_Form VALUES
($First_Name,$Last_Name,$Address,$City,$State,$Zip,$Country,$phone,$E-mail,$email,$Product01,$Product02);
needs to be (for example. you need to change it to match your column names):
$query = "INSERT INTO Order_Form (First_Name, Last_Name, Address) VALUES ('$First_Name','$Last_Name','$Address')";
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)
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 June 2006 - 07:41 AM

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();
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users