Jump to content


Photo

PHP Form help


  • Please log in to reply
4 replies to this topic

#1 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 June 2006 - 12:46 PM

what is wrong with this code? can any one help please. I have tried evrything


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


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 June 2006 - 01:04 PM

What's wrong with it? What does it do? What doesn't it do that you expect? What error messages does it generate? I'm skeptical about the username and database name you use in your code. Normally, the username and database name have your web account username as part of them. Don't post your real database access details (you never know who's reading these posts), but do check that what you are using makes sense.
Legend has it that reading the manual never killed anyone.
My site

#3 rscott7706

rscott7706
  • Members
  • PipPipPip
  • Advanced Member
  • 88 posts
  • LocationLakeside CA

Posted 23 June 2006 - 01:19 PM

I am a newbie also, but I think one problem is using e-mail.

PHP wants to see this as e minus mail - mathmatical operation.

Make it email. And just a suggestion - whay not first or fn and
last or ln instead of the long winded titles you have.

#4 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 23 June 2006 - 02:18 PM

[!--quoteo(post=387148:date=Jun 23 2006, 09:19 AM:name=RonScott)--][div class=\'quotetop\']QUOTE(RonScott @ Jun 23 2006, 09:19 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
I am a newbie also, but I think one problem is using e-mail.

PHP wants to see this as e minus mail - mathmatical operation.

Make it email. [/quote]

Great catch, Ron. MySQL would choke on e minus mail (and error trapping in the OP's script should show that).

Legend has it that reading the manual never killed anyone.
My site

#5 gfmaking

gfmaking
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 June 2006 - 05:35 PM

Hi Andy,

I used HTML Form to submit contact and order info to my mysql database. When Submiting the form balnk page apears & nothing was been inserted in to the database. Of course I used "post" method for my HTML form and I saved the above code in to action.php file.

Please look in to it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users